I have the following code. Just before the update statement below I call a public sub. I want to pass two work variables to this new public sub. One is text the other numeric. When I can get the SQL to work I then want to populate the item field in ![partnumber], the third field below form the SQL. I cannot get the SQL to work. I am working in Access.
Do While Not rstsrc.EOF
KeyField = rstsrc![entrysummarynumber] & rstsrc![entrysummarylinenumber] 'Sets unique value in new record using entry, line and ordinal
With rstupd
.AddNew
![esunique] = KeyField
![entrysummarynumber] = rstsrc![entrysummarynumber]
![PartNumber] = part
![EntryTypeCode] = rstsrc![EntryTypeCode]
![importerNumber] = rstsrc![importerNumber]
![PortofEntryCode] = rstsrc![importerNumber]
![EntryDate] = rstsrc![EntryDate]
![EntrySummaryDate] = rstsrc![EntrySummaryDate]
![EntrySummaryCreateDate] = rstsrc![EntrySummaryCreateDate]
![entrysummarylinenumber] = rstsrc![entrysummarylinenumber]
Work variables:
wrkentry = ![entrysummarynumber]
wrkentrynum = ![entrysummarylinenumber]
Call GetKNPn(wrkentry, wrkentrynum)
.Update
Public Sub GetKNPn(wrkentry, wrkentryline)
Set rstkndcr = db.OpenRecordset("SELECT [KNDCR].[Item] from KNDCR where KNDCR.[ENTRY] = wrkentry AND KNDCR.[ENTRYSUMMARYLINE] = wrkentryline")
Do While Not rstsrc.EOF
KeyField = rstsrc![entrysummarynumber] & rstsrc![entrysummarylinenumber] 'Sets unique value in new record using entry, line and ordinal
With rstupd
.AddNew
![esunique] = KeyField
![entrysummarynumber] = rstsrc![entrysummarynumber]
![PartNumber] = part
![EntryTypeCode] = rstsrc![EntryTypeCode]
![importerNumber] = rstsrc![importerNumber]
![PortofEntryCode] = rstsrc![importerNumber]
![EntryDate] = rstsrc![EntryDate]
![EntrySummaryDate] = rstsrc![EntrySummaryDate]
![EntrySummaryCreateDate] = rstsrc![EntrySummaryCreateDate]
![entrysummarylinenumber] = rstsrc![entrysummarylinenumber]
Work variables:
wrkentry = ![entrysummarynumber]
wrkentrynum = ![entrysummarylinenumber]
Call GetKNPn(wrkentry, wrkentrynum)
.Update
Public Sub GetKNPn(wrkentry, wrkentryline)
Set rstkndcr = db.OpenRecordset("SELECT [KNDCR].[Item] from KNDCR where KNDCR.[ENTRY] = wrkentry AND KNDCR.[ENTRYSUMMARYLINE] = wrkentryline")