You MUST concatenate the number (vOptionNumber) to the SQL string.
Try this - Add the line in BLUE (your code):
Code:
Dim vOptionNumber As Long
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
vOptionNumber = Nz([cmbInstallationNoteTitle], 0) + Nz([cmbInstallationNoteTitle_LongList], 0)
' results in a valid number
strSQL = "SELECT * FROM [tbeInstallationNotes] WHERE [InstallationNote_OptionNumber] = vOptionNumber; "
' tbeInstallationNotes is a properly spelled valid table
' InstallationNote_OptionNumber is a properly spelled field with a number data type
Debug.Print strSQL
'Set a breakpoint on the next line so you can see the immediate window
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset(strSQL)
' and of course this is where the error occurs
With rst
DoCmd.GoToRecord , "", acFirst
Do Until .EOF
<...>
Look at the immediate window.
Now change the code to this (modified code):
Code:
Dim vOptionNumber As Long
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
vOptionNumber = Nz([cmbInstallationNoteTitle], 0) + Nz([cmbInstallationNoteTitle_LongList], 0)
' results in a valid number
strSQL = "SELECT * FROM [tbeInstallationNotes] WHERE [InstallationNote_OptionNumber] = " & vOptionNumber & ";"
' tbeInstallationNotes is a properly spelled valid table
' InstallationNote_OptionNumber is a properly spelled field with a number data type
Debug.Print strSQL
'Set a breakpoint on the next line so you can see the immediate window
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset(strSQL)
' and of course this is where the error occurs
With rst
DoCmd.GoToRecord , "", acFirst
Do Until .EOF
<...>
Look at the immediate window. What is the difference???