View Full Version : Passing inputbox value


TimE
04-08-2007, 04:15 PM
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?


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.


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!!!

llkhoutx
04-08-2007, 06:28 PM
When a value is not entered in your inputbox, then return a subroutine parameter which will cause the inputbox open again.

TimE
04-08-2007, 06:41 PM
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?

boblarson
04-08-2007, 06:45 PM
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) & "')"

TimE
04-08-2007, 07:48 PM
Thank you boblarson.....The answer was staring at me the whole time (the rest of the statement :o ).