Ok, I am losing my mind... I have no idea why this is happening - that being why I can't store a null value, sourced from a table via a query into a variable, that is to be later used in an insert. When I get to the part where I set the value for the variable I get the evil: Invalid use of Null: Error 94.
I imagine it must be something basic since I have no idea what is wrong with this.
Code:
Private Sub btnImportAll_Click()
MsgBox ("Calling Bulk Import")
strSQL = "Select * From tblImportContacts"
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
If rst.RecordCount > 0 Then
'MsgBox ("rst.RecordCount:" & rst.RecordCount)
rst.MoveFirst
Do While Not rst.EOF
MsgBox ("attempting to insert member")
InsertTblMember
' InsertTblAddress
' InsertTblMemberAddress
' InsertTblMemberCommunications
' InsertTbListMembers
rst.MoveNext
Loop
End If
End Sub
Function InsertTblMember()
MsgBox ("Calling Insert TblMember(1)")
txtLname = rst("Lname").Value
MsgBox ("txtLname : " & txtLname)
txtFname = rst("Fname").Value
MsgBox ("txtFname: " & txtFname)
txtSuffix = rst("Suffix").Value
MsgBox ("txtSuffix: " & txtSuffix)
txtSalutation = rst("Salutation").Value '<------ Invalid Use of Null here
MsgBox ("txtSalutation after: " & txtSalutation)
' insert new record(s) with updated values
strSQL = "INSERT INTO tblMember (lname, fname, salutation, suffix) VALUES (""" & txtLname & """,""" & txtFname & """,""" & txtSalutation & """,""" & txtSuffix & """);"
'MsgBox ("strSQL: " & strSQL)
DoCmd.RunSQL strSQL
txtLname = ""
txtFname = ""
txtSuffix = ""
txtSalutation = ""
[code]
Why can't I store null in that txtSalutation variable, which I have declared as a string and a public var?
I've even tried:
txtSalutation = nz(rst("Salutation").Value, null)
I *want* to store a null for when I use this variable for the insert.
What gives?
What am I doing wrong?
Ugh.
Thanks for any thoughts... I need a drink...