ScottK1396
Registered User.
- Local time
- Today, 00:58
- Joined
- Jul 28, 2011
- Messages
- 20
I have been trying to use DAO.recordset to more quickly populate form fields in a new project. It seems as though I have it set up properly, however it keeps throwing the same error.
I have a lookup form that I want to take a scanned serial number and tell what the scanned item is from our asset data source. I also will be adapting to create a snapshot inventory tool, independent of production.
I am using the Serial number (alpha string) from a text box to perform a lookup against a linked ODBC SQL database.
However, Access throws the following error on the highlighted line:
Run-time error '3070':
The Microsoft Access Database engine does not recognize 'J2K4K6' [the value of Me!ScannedText] as a valid field name or expression.:banghead:
I fell back to DLookup, using a previous project as template for parameters
The error thrown here is :
Run-time error'2471':
The expression you entered as a query parameter produces this error: 'SerialScan':banghead:
The only differences is that I used using a numerical list index in previous effort, and a string here. Also using a R/O SQL table instead of a SharePoint R/W table.
I read up the primer from Utter Access (thanks pr2-eugin), I think I followed convention, but I probably got all of the quotes and brackets hosed up.
I have a lookup form that I want to take a scanned serial number and tell what the scanned item is from our asset data source. I also will be adapting to create a snapshot inventory tool, independent of production.
I am using the Serial number (alpha string) from a text box to perform a lookup against a linked ODBC SQL database.
Code:
'Populate form fields from serial scan
Dim SerialScan As String
SerialScan = Me!txtScannedText
Dim rstC As DAO.Recordset
Set rstC = CurrentDb.OpenRecordset("ASTM_devices_all_state", dbOpenSnapshot)
[B][COLOR=red]! [/COLOR][/B][COLOR=red][B]>[/B][/COLOR] [COLOR=red]rstC.FindFirst "[Serial] = " & SerialScan[/COLOR]
If rstC.NoMatch Then
txtASTMTag.Text = "NOT FOUND"
txtASTMMfrModel.Text = "--"
txtASTMModelnum.Text = "--"
txtASTMLocation.Text = "--"
txtASTMAssignment.Text = "--"
txtASTMUsername.Text = "--"
Else
txtASTMMfrModel.Text = rstC!mfr_modelname
txtASTMModelnum.Text = rstC!Model
txtASTMLocation.Text = rstC!Location
txtASTMAssignment.Text = rstC!Assignment
txtASTMUsername.Text = rstC!Name
End If
Set rstC = Nothing
However, Access throws the following error on the highlighted line:
Run-time error '3070':
The Microsoft Access Database engine does not recognize 'J2K4K6' [the value of Me!ScannedText] as a valid field name or expression.:banghead:
I fell back to DLookup, using a previous project as template for parameters
Code:
Dim SerialScan As String
SerialScan = Me!txtScannedText
txtASTMMfrModel.Text = DLookup("[mfr_modelname]", "[ASTM_devices_all_state]", "[ASTM_devices_all_state].[Serial] = [SerialScan]")
The error thrown here is :
Run-time error'2471':
The expression you entered as a query parameter produces this error: 'SerialScan':banghead:
The only differences is that I used using a numerical list index in previous effort, and a string here. Also using a R/O SQL table instead of a SharePoint R/W table.
I read up the primer from Utter Access (thanks pr2-eugin), I think I followed convention, but I probably got all of the quotes and brackets hosed up.