J
Joe
I call the following function, which looks up the numeric
value iRecord, which I want to use as the criteria to look
up the information from the second query. This works fine
and prints the appropriate value in the immediate window
following the debug.print line, the problem occurs when
iRecord is used an error message "The Microsoft Jet
database does not recognise 'iRecord' as a valid field
name or expression". Should the iRecord value be converted
to a text value along with the value in the field payref.
If so some help with the syntax would be appreciated.
Dim dbnewpayments As DAO.Database
Dim rcdWOlines As DAO.Recordset
Set dbnewpayments = CurrentDb
Set rcdWOlines =
_dbnewpayments.OpenRecordset "qryWOlookup")
Dim iRecord As Variant
Dim iSCompany As Variant
rcdWOlines.FindFirst "ALTCODE = 'WO' And [WOtest] = no"
If Not rcdWOlines.NoMatch Then
iRecord = rcdWOlines![record]
Debug.Print iRecord
Dim dbINVpayments As DAO.Database
Dim rcdINVlines As DAO.Recordset
Set dbINVpayments = CurrentDb
Set rcdINVlines = dbnewpayments.OpenRecordset_
("qryinvlookup")
rcdINVlines.FindFirst "payref = iRecord"
value iRecord, which I want to use as the criteria to look
up the information from the second query. This works fine
and prints the appropriate value in the immediate window
following the debug.print line, the problem occurs when
iRecord is used an error message "The Microsoft Jet
database does not recognise 'iRecord' as a valid field
name or expression". Should the iRecord value be converted
to a text value along with the value in the field payref.
If so some help with the syntax would be appreciated.
Dim dbnewpayments As DAO.Database
Dim rcdWOlines As DAO.Recordset
Set dbnewpayments = CurrentDb
Set rcdWOlines =
_dbnewpayments.OpenRecordset "qryWOlookup")
Dim iRecord As Variant
Dim iSCompany As Variant
rcdWOlines.FindFirst "ALTCODE = 'WO' And [WOtest] = no"
If Not rcdWOlines.NoMatch Then
iRecord = rcdWOlines![record]
Debug.Print iRecord
Dim dbINVpayments As DAO.Database
Dim rcdINVlines As DAO.Recordset
Set dbINVpayments = CurrentDb
Set rcdINVlines = dbnewpayments.OpenRecordset_
("qryinvlookup")
rcdINVlines.FindFirst "payref = iRecord"