Results 1 to 10 of 10
  1. #1
    Gregory23 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    28

    Run-time error 3075

    Hi ,

    I get the below error msg when cancel is clicked , anyone can help ?





    This is the VBA code below

    Private Sub btnPrint_Click()

    DoCmd.OpenForm "Order form", acViewPreview, , "[Invoice no] = " & InputBox("Enter invoice no")

    End SubClick image for larger version. 

Name:	error.JPG 
Views:	24 
Size:	16.9 KB 
ID:	26309

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Cancel returns a zero length string. Get the input and test before trying to open the form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Gregory23 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    28
    Hello

    Dont really know how to "Cancel returns a zero length string and Get the input" ?

    Click image for larger version. 

Name:	Capture.JPG 
Views:	18 
Size:	16.5 KB 
ID:	27606

    Can you advise where and what to put into the above code ?

    Thank you

  4. #4
    NTC is offline VIP
    Windows 10 Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    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.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    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
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by NTC View Post
    I don't get this syntax: & InputBox("Enter invoice no")

    That's acceptable syntax for an InputBox. There are other arguments, but they're not required. The text in quotes is what the user will be shown; no variables involved.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    NTC is offline VIP
    Windows 10 Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    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....

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    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.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Gregory23 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    28
    Hello

    Issue resolved

    Thank you for the help

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Glad you got it sorted.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 01-04-2016, 09:40 AM
  2. Replies: 2
    Last Post: 09-10-2014, 11:30 AM
  3. Replies: 11
    Last Post: 05-01-2014, 11:56 AM
  4. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  5. Replies: 6
    Last Post: 05-30-2012, 12:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums