Passing inputbox value

TimE

Registered User.
Local time
Yesterday, 22:38
Joined
May 17, 2005
Messages
55
1) I would like to pass the value of an inputbox to a sql statment:

2) The "If IsNull(stAuthDocIn) Then" is not working, how should it be done?

Code:
Private Sub AuthDocIn()
    Dim stAuthDocIn
    stAuthDocIn = InputBox("Please enter the authorizing document #.", "AUTHORIZING DOCUMENT")
        If IsNull(stAuthDocIn) Then
            MsgBox "You MUST enter the authorizing document!", vbOKOnly + vbCritical, "Authorizing Document!"
            End If
End Sub


Here is the piece I use to add it to a table. I want to pass the value of the Inputbox to the value of a field. When it runs this piece, it brings up another msgbox asking for the value of stAuthDocIn.

Code:
DoCmd.RunSQL "INSERT INTO tblDCscan([AUTH_DOC_IN], [ASSET_TAG], [SERIAL_NUM], [MAKE], [MODEL], [DESCRIPTION], [CATEGORYCODE], [RETIRE_DATE]) " & _
    "VALUES (stAuthDocIn, '" & Me![SelectionList].Column(0) & "', '" & Me![SelectionList].Column(1) & "','" & Me![SelectionList].Column(3) & "', '" & Me![SelectionList].Column(4) & "','" & Me![SelectionList].Column(5) & "', '" & Me![SelectionList].Column(6) & "', '" & Me![SelectionList].Column(7) & "')"


Stumped!!!
 
When a value is not entered in your inputbox, then return a subroutine parameter which will cause the inputbox open again.
 
Thank you for your help, I will try it.

Any thoughts on how to pass the value of the inputbox "stAuthDocIn" to the SQL INSERT statement?
 
DoCmd.RunSQL "INSERT INTO tblDCscan([AUTH_DOC_IN], [ASSET_TAG], [SERIAL_NUM], [MAKE], [MODEL], [DESCRIPTION], [CATEGORYCODE], [RETIRE_DATE]) " & _
"VALUES ('" & stAuthDocIn & " '," & Me![SelectionList].Column(0) & "', '" & Me![SelectionList].Column(1) & "','" & Me![SelectionList].Column(3) & "', '" & Me![SelectionList].Column(4) & "','" & Me![SelectionList].Column(5) & "', '" & Me![SelectionList].Column(6) & "', '" & Me![SelectionList].Column(7) & "')"
 
Thank you boblarson.....The answer was staring at me the whole time (the rest of the statement :o ).
 

Users who are viewing this thread

Back
Top Bottom