Results 1 to 6 of 6
  1. #1
    ieX is offline Novice
    Windows 8 Access 2007
    Join Date
    Dec 2017
    Posts
    3

    Please help me with this..

    Click image for larger version. 

Name:	Untitled10212.jpg 
Views:	21 
Size:	6.2 KB 
ID:	31502 <<< this is a screenshot on my form
    Click image for larger version. 

Name:	Untitled10212 - Copy.jpg 
Views:	17 
Size:	23.6 KB 
ID:	31503<<< this is my expected input on my table.

  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,652
    You can use the AddNew method of a recordset and a For/Next loop that uses the form textboxes.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ieX is offline Novice
    Windows 8 Access 2007
    Join Date
    Dec 2017
    Posts
    3
    Thank you sir. It took me a few hours solving it since I'm new with access.

  4. #4
    ieX is offline Novice
    Windows 8 Access 2007
    Join Date
    Dec 2017
    Posts
    3
    Private Sub cmdinput_Click()
    'here is my code just in case someone has the same problem hope this help.
    Dim LCounter As Integer
    Dim ID As Long
    DoCmd.GoToRecord , , acNewRec
    Text19 = Me.txtbegining
    For LCounter = Me.txtbegining To (Me.txtend - 1)
    DoCmd.GoToRecord , , acNewRec
    ID = DMax("sampleID", "sample")
    Text19 = DLookup("serial_number", "sample", "sampleID=" & ID) + 1
    Next
    DoCmd.Requery

    End Sub

  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,652
    Why not just use the LCounter value to set the value? Your code would not necessa use the values from the form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Here is an alternative:
    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub cmdinput_Click()
        Dim LCounter As Integer
        Dim lngBegining As Long
        Dim lngEnd As Long
        Dim sSQL As String
    
        'get starting and ending numbers
        lngBegining = Me.txtbegining
        lngEnd = Me.txtend
    
        For LCounter = lngBegining To lngEnd
            sSQL = "INSERT INTO sample(serial_number) VALUES (" & LCounter & ");"
            CurrentDb.Execute sSQL, dbFailOnError
        Next
    
        DoCmd.Requery
    
    End Sub

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

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