having trouble with code

Tony1258

Registered User.
Local time
Today, 16:42
Joined
Jun 8, 2006
Messages
29
I am trying to get the following code eto look for a account number and if it is found update the value. I can get that to work but if the account is not found I want to force an account number and I cannot seem to get it to work. Any help would be appreciated.

Tony

intValue = DLookup("KY_BA", "OLDACCOUNTS", "[OLDACCOUNTS].[OldAcct]=" & rs![ky_ba])


if Not IsNull(intValue) Then

strsql = "UPDATE [TABLE_ONE] SET [TABLE_ONE].KY_BA = " & intValue
strsql = " UPDATE [TABLE_ONE]Set [TABLE_ONE].[KY_BA] = 4999999999"

DoCmd.RunSQL strsql
 
Afaik you can't make an integer null in VBA. You would have to declare your variable as type variant.

i would avoid using null as part of your solution though. Either use recordsets as Tony suggests or use dcount to see if there are zero records or not.
Chris
 

Users who are viewing this thread

Back
Top Bottom