Testing for no value

artanis50

New member
Local time
Today, 14:03
Joined
Dec 22, 2011
Messages
6
Hello, I am a total newbie to vba and trying to learn on the job. I am trying to test if a value in one of my tables is null. If it is, I want to return an error message and ask the user if they want to continue. If it is not null, I don't want to see any error message and just continue the process. Any ideas what is wrong here:

If IsNull(NHSNASA) Then
Dim Response As VbMsgBoxResult
Response = MsgBox("At least 1 ASA Score is Missing. Do you want to continue?", vbQuestion + vbYesNo, "ALERT")
If Response = vbYes Then
MsgBox "You will not be able to upload data to NHSN until the missing ASA Scores are updated"
Else: DoCmd.CloseDatabase
End If
Else
End If
 
Amended:
Code:
    If Len(Nz(NHSNASA, vbNullString)) Then
        If MsgBox("At least 1 ASA Score is Missing. Do you want to continue?", vbQuestion + vbYesNo, "ALERT") = vbYes Then
            MsgBox "You will not be able to upload data to NHSN until the missing ASA Scores are updated"
        Else
            DoCmd.CloseDatabase
        End If
    End If

That's very hars --> DoCmd.CloseDatabase ;)
 
LOL Well I'm the only one using the database and I'd need to close it to fix the issue anyway so it saves me a step! Still need help on the IsNull piece if anyone can shed some light for me!
 

Users who are viewing this thread

Back
Top Bottom