Cancel returns a zero length string. Get the input and test before trying to open the form.
I don't get this syntax: & InputBox("Enter invoice no")
In particularly the ( ) and " " unless you've dimmed a variable with that string I doubt it will work.
Simplify temporarily to sanity check.
Since yours looks like it should be a number, this type of thing:
Code:Dim strChoice As String strChoice = InputBox("Whatever") If IsNumeric(strChoice) Then DoCmd.OpenForm "Order form", acViewPreview, , "[Invoice no] = " & strChoice Else MsgBox "must enter number" End If
well live & learn - thanks Paul.... hate parameter prompts so probably won't use this either. msdn says:
Dim message, title, defaultValue As String
Dim myValue As Object
' Set prompt.
message = "Enter a value between 1 and 3"
' Set title.
title = "InputBox Demo"
defaultValue = "1" ' Set default value.
' Display message, title, and default value.
myValue = InputBox(message, title, defaultValue)
' If user has clicked Cancel, set myValue to defaultValue
If myValue Is "" Then myValue = defaultValue
' Display dialog box at position 100, 100.
myValue = InputBox(message, title, defaultValue, 100, 100)
' If user has clicked Cancel, set myValue to defaultValue
If myValue Is "" Then myValue = defaultValue
so leaving out the unwanted parameters after the prompt - it would be best to structure per example above
as I've not seen questions on this method previously I am wondering as to which edition it began or whether it has been there all along....
It's certainly been there since 2000. I used 97 a little bit, but didn't seriously develop with it. I don't use InputBox much, but it can be a handy way to get user input during a process.
Hello
Issue resolved
Thank you for the help