Results 1 to 7 of 7
  1. #1
    sukhjinder's Avatar
    sukhjinder is offline Beginner
    Windows 10 Access 2016
    Join Date
    May 2016
    Posts
    43

    Data from text box through loop

    I AM USING THE FOLLOWING CODE WITH THIS THE PROGRAM IS RUNNING BUT it is showing the text boxes empty

    Private Sub cmdsave_Click()
    Dim sSQL As String
    Dim i As Integer


    Dim data As Double
    Dim mode As Integer

    For i = 1 To 7
    data = txtde & i
    mode = cbo & i
    sSQL = "INSERT INTO tbl_data (dataentry,mode )"
    sSQL = sSQL & " VALUES(" & data & "," & mode & " );"
    Debug.Print sSQL
    Next

    MsgBox "SUCCESS!!!"


    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,526
    this should take about 1 to 2 seconds to run.
    As long as cbo is not null, textDe is not null, and both fields in the target table are numeric (not string)

  3. #3
    sukhjinder's Avatar
    sukhjinder is offline Beginner
    Windows 10 Access 2016
    Join Date
    May 2016
    Posts
    43
    entervalueform.zip
    Quote Originally Posted by ranman256 View Post
    this should take about 1 to 2 seconds to run.
    As long as cbo is not null, textDe is not null, and both fields in the target table are numeric (not string)
    yes this is running but the data entered by me in the text boxes is not displayed

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    The fields on the form must be "data = Me("txtde" & i)", same for cbo.

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,526
    if the combo box name called cbo, and the VALUE of cbo = 6, and you want to add i to the value:
    mode = cbo & i
    mode = 6 + 1
    mode = 7

    if the combo box NAME is called cbo1, and cbo1 = 6, and you are cycling thru all cbo's 1 thru 7, then
    mode = controls(cbo & 1)
    mode = 6

  6. #6
    sukhjinder's Avatar
    sukhjinder is offline Beginner
    Windows 10 Access 2016
    Join Date
    May 2016
    Posts
    43
    Quote Originally Posted by aytee111 View Post
    The fields on the form must be "data = Me("txtde" & i)", same for cbo.
    Thanks aytee111 this works fine for me

  7. #7
    sukhjinder's Avatar
    sukhjinder is offline Beginner
    Windows 10 Access 2016
    Join Date
    May 2016
    Posts
    43
    I have used aytee111 method that works perfect and no problem in cycling thru.

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

Similar Threads

  1. Update MS Access Marquee text on each loop
    By iainct in forum Modules
    Replies: 1
    Last Post: 06-20-2016, 04:28 AM
  2. Replies: 12
    Last Post: 06-05-2015, 04:27 PM
  3. Replies: 17
    Last Post: 04-07-2014, 07:48 PM
  4. DSUM Text Box Stuck in a loop
    By Jademonkey2k in forum Access
    Replies: 7
    Last Post: 11-23-2010, 07:15 PM
  5. Cycle Text Boxes with a For next loop
    By Gary in forum Programming
    Replies: 3
    Last Post: 07-20-2010, 09:32 AM

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