Results 1 to 9 of 9
  1. #1
    mladen273 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2012
    Location
    Zagreb, Croatia
    Posts
    19

    Inputbox

    How do I get to repeat the command.
    For example, now after each entry barcode must touch the "command7" to enter the new barcode.
    I wish to have it automatically opens after entering barcode.
    How to write code when I click on Cancel to pop up "InputBox" goes out?

    This is code:

    Private Sub Command21_Click()
    Dim Barkod As String
    Dim RunSQL As String

    Barkod = Inputbox("Upiši barkod", "Barkod")

    DoCmd.SetWarnings False
    DoCmd.RunSQL "INSERT INTO Sken VALUES ('" & Barkod & "');"
    DoCmd.RunMacro ("m_Refresh")





    End Sub

  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
    You can add a GoTo and return to the point above the InputBox(). You can test for "" which I believe is what hitting Cancel will return.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    mladen273 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2012
    Location
    Zagreb, Croatia
    Posts
    19
    How write command for GoTo?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    There are examples in VBA help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    mladen273 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2012
    Location
    Zagreb, Croatia
    Posts
    19
    Quote Originally Posted by pbaldy View Post
    There are examples in VBA help.
    Be a friend and write ...
    I don't know very well VBA

    Buy you a beer

  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
    Here, I went to help for you.

    Click image for larger version. 

Name:	GoTo.jpg 
Views:	21 
Size:	152.6 KB 
ID:	10501
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    mladen273 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2012
    Location
    Zagreb, Croatia
    Posts
    19
    I really appreciate your efforts, but like I said, I am a beginner in VBA and I do not know how to adjust it according to command .
    Please, could you write the code. I really need this.

    Greetings from Croatian

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    A different approach:
    Code:
    Private Sub Command21_Click()
    Dim Barkod As String
    
    Barkod = "?"
    While Barkod = "?"
       Barkod = Inputbox("Upiši barkod", "Barkod")
       If Barkod <> "" Then
          CurrentDb.Execute "INSERT INTO Sken VALUES ('" & Barkod & "');"
          DoCmd.RunMacro ("m_Refresh")
          Barkod = "?"
       End If
    Wend
    
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    mladen273 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2012
    Location
    Zagreb, Croatia
    Posts
    19
    Thanks, now everything works !!!

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

Similar Threads

  1. Checking which query is invoking inputbox?
    By ravenq1 in forum Queries
    Replies: 1
    Last Post: 01-12-2012, 05:05 PM
  2. inputbox that accepts numbers
    By bbrazeau in forum Forms
    Replies: 2
    Last Post: 11-01-2011, 06:08 AM
  3. Type mismatch from InputBox
    By sephiroth2906 in forum Programming
    Replies: 2
    Last Post: 09-15-2011, 06:59 AM
  4. Inputbox on programming? :(
    By radicrains in forum Programming
    Replies: 7
    Last Post: 11-05-2010, 10:58 PM
  5. Query & InputBox
    By RemusRigo in forum Queries
    Replies: 1
    Last Post: 03-25-2009, 08:21 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