Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem defining a reference for a field name in a FindFirst method

Status
Not open for further replies.

rlh145

Programmer
Feb 19, 2001
36
US
I can't seem to get a field name reference correctly for use in a FindFirst method. Here is the logic I am using:

Private Sub PageHeaderSection_Print(Cancel As Integer, PrintCount As Integer)

Dim StrSql As String
Dim StrCriteria As String
Dim StrCriteria1 As String
Dim StrCriteria2 As String


StrSql = "tblBioclass"
Set DB = CurrentDb

StrCriteria1 = Reports![rptFishComm]![tblCCNum].Value


Set LogIt = DB.OpenRecordset(StrSql, dbOpenDynaset)

StrCriteria = " Logit![CCNum] = 'StrCriteria1' "
'StrCriteria2 = LogIt![CCNum]

LogIt.FindFirst StrCriteria
LogIt.Edit
LogIt("Bioclass") = bioclass([txtNorate], [txtIBI])
LogIt.Update
LogIt.Close


End Sub

Now Here is the error message I am getting:

Runtime error '3070'

The Microsoft Jet database engine does not recognize 'Logit!ccnum' as a valid field name or expression.

There is a line in this code that has been commented out that I used to prove to myself that this field has a value in it. It is 'StrCriteria2 = .....'

I am stumped not being able to develop a satisfactory string expression for that field. All I want to do is use the FindFirst method to search the tblBioclass table to find the first record that matches the value found in StrCriteria1 in the ccnum field in the tblBioClass field.


I hope that I have given enough information. Thanks for any help you can offer me!!

Ralph




 
Hi

You are searching for the string strCriteria1 instaed of the contents of it, try:

StrCriteria = " Logit![CCNum] = '" & StrCriteria1 & "' "
Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
StrCriteria = " Logit![CCNum] = '" & StrCriteria1 & "' "

No Space before the FIELD NAME
No TableName before FIELD Name
No Space following the criteria


strCriteria = "[CCNum] = " & Chr(34) & strCriteria1 & Chr(34) MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top