使用记录中的文本粘贴到Access表单控件框中 [英] Use text from record to paste into an Access form controlbox

查看:80
本文介绍了使用记录中的文本粘贴到Access表单控件框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于用户的工作ID号,我创建一个ID的记录集,该ID的记录集具有不同的单位类型(例如管道尺寸)和单位(例如管道素材).每个单位类型记录都已经具有表单文本框的名称,其中总镜头在不同的列中.我要做的是遍历每个记录集,并为该作业ID号(用户以表格形式输入)插入每种单位类型的素材.

Based on a user's job ID number, I create a recordset of an ID with its different unit types (think pipe sizes) and unit (think footage of pipe). Each unit type record already has the name of the form textbox where the total footage goes in a different column. What I want to do is go through each recordset and plugin the footage for each unit type for that job ID number (that the user puts in a form).

Dim rst_UnitEntryCounts As Recordset   
Set rst_UnitEntryCounts = CurrentDb.OpenRecordset("SELECT tbl_UnitTypes.UnitTypes_WeeklyTextBoxUserEntryForm, " _
                                                        & "             tbl_PMEntry.PMEntry_Week_Ending, " _
                                                        & "             tbl_UnitTypes.UnitTypes_CumalativeTextBoxUserEntryForm, " _
                                                        & "             Sum(tbl_UnitEntry.UnitEntry_Unit_Count) AS SumOfUnitEntry_Unit_Count " _
                                                        & "FROM tbl_UnitTypes " _
                                                        & "         INNER JOIN tbl_UnitEntry ON tbl_UnitTypes.UnitTypes_ID = tbl_UnitEntry.UnitEntry_UnitTypes_ID) " _
                                                        & "         INNER JOIN (tbl_PMHeader " _
                                                        & "         INNER JOIN tbl_PMEntry ON tbl_PMHeader.PMHeader_ID = tbl_PMEntry.PMEntry_PMHeader_ID) ON tbl_UnitEntry.UnitEntry_PMEntry_ID = tbl_PMEntry.PMEntry_PMHeader_ID " _
                                                        & "WHERE tbl_PMHeader.PMHeader_ID = " & num_PM _
                                                        & "GROUP BY tbl_UnitTypes.UnitTypes_WeeklyTextBoxUserEntryForm, " _
                                                        & "             tbl_PMEntry.PMEntry_Week_Ending, " _
                                                        & "             tbl_UnitTypes.UnitTypes_CumalativeTextBoxUserEntryForm ")
            rst_UnitEntryCounts.MoveFirst
            Do Until rst_UnitEntryCounts.EOF = True
                [rst_UnitEntryCounts.UnitTypes_WeeklyTextBoxUserEntryForm] = SumOfUnitEntry_Unit_Count
            rst_UnitEntryCounts.MoveNext
            Loop
    Exit Sub

查询表的外观图像 另外,我在FROM子句中也收到错误3131语法错误. 预先感谢!

image of what my query table looks like Also, Im getting an error 3131 Syntax error in FROM clause as well. Thanks in advance!

推荐答案

最后弄清楚了如何在一个文本框中放置"一个值(单位和),该文本框根据表单中的条件(单位类型)而有所不同,其中文本框的名称位于我的记录集中的记录本身内.如果有人有类似的问题,这是我的做法:

Finally figured out how to "place" a value (sum of units) in a textbox that varies based on criteria (unit type) in a form, where the name of the textbox is inside a record itself within my recordset. In case someone else has a similar question, here is how I did it:

Dim cntl As String
 Dim frm As String
 Dim rst_UnitEntry As Recordset
 frm = "frm_UserEntry"

Set rst_UnitEntryCounts = CurrentDb.OpenRecordset("SELECT...)     
If rst_UnitEntryCounts.RecordCount <> 0 Then
        rst_UnitEntryCounts.MoveFirst
        Do Until rst_UnitEntryCounts.EOF = True
        If rst_UnitEntryCounts![UnitTypes_CumalativeTextBoxUserEntryForm] <> "" Then
            cntl = rst_UnitEntryCounts![UnitTypes_CumalativeTextBoxUserEntryForm]
            Forms(frm).Controls(cntl) = rst_UnitEntryCounts![SumOfUnitEntry_Unit_Count]
        End If
        rst_UnitEntryCounts.MoveNext
        Loop

这篇关于使用记录中的文本粘贴到Access表单控件框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆