Hello folks, have a fairly simple question that I am sure has a simple solution, I am just not experienced enough to know the answer.
I have the following VBA code on an "On Enter" event on a field. The code work beautifully for what I want it to do, unless the user clicks in an empty field to create a new record, at which point access returns an error saying "Invalid use of Null". I know I need to include Null handing for this, but I dont know where in the code I need to add it or specifically how I would do so for this specific instance.
Code:
Private Sub OlSerialNumber_Enter()
Dim dbs As Database, strSQL As String
Dim PassID As String
PassID = Me!OlDescription
Set dbs = CurrentDb
strSQL = "SELECT [AssetData].[SerialNumber], [AssetData].[Identifier] FROM AssetData Left JOIN OperatingLog ON [AssetData].[Identifier] = [OperatingLog].[OlDescription] WHERE [AssetData].[Identifier]='" & PassID & "';"
Me!OlSerialNumber.RowSource = strSQL
End Sub
Any help would be much appreciated, as I am going to need to replicate this code to several other fields on the form for the auto update process I have defined.
EDIT: I dont know why i didnt debug the code before posting this, but the debug flashes the line where I declare the value for the varibale "PassID".