T
tted78
I'm trying to use a program developed in Access 2000 in Access 2007.
Supposedly the old program should work, but the following bit of VBA coding
fails. The value of "strPick" is not known in the Where clause and the user
is prompted for the value. I use MSGBOX to check the value immediately
before the statement and all is well. Can anyone give me a clue as to the
problem in 2007?
Dim strSQL As String, strPick As String
Dim MyBox As ListBox
Set MyBox = [Forms]![Family Display Selection]![ListNames]
strPick = MyBox.Value
strSQL = "DELETE [SSNPick].* " & _
"FROM [SSNPick];"
DoCmd.RunSQL strSQL
MsgBox "strpick " + [strPick]
strSQL = "INSERT INTO [SSNPick] ( SSNPicked ) " & _
"SELECT ALL [SSN Found].SearchSSN " & _
"FROM [SSN Found] " & _
"WHERE ([SSN Found].SearchName = strPick);"
DoCmd.RunSQL strSQL
Supposedly the old program should work, but the following bit of VBA coding
fails. The value of "strPick" is not known in the Where clause and the user
is prompted for the value. I use MSGBOX to check the value immediately
before the statement and all is well. Can anyone give me a clue as to the
problem in 2007?
Dim strSQL As String, strPick As String
Dim MyBox As ListBox
Set MyBox = [Forms]![Family Display Selection]![ListNames]
strPick = MyBox.Value
strSQL = "DELETE [SSNPick].* " & _
"FROM [SSNPick];"
DoCmd.RunSQL strSQL
MsgBox "strpick " + [strPick]
strSQL = "INSERT INTO [SSNPick] ( SSNPicked ) " & _
"SELECT ALL [SSN Found].SearchSSN " & _
"FROM [SSN Found] " & _
"WHERE ([SSN Found].SearchName = strPick);"
DoCmd.RunSQL strSQL