Saving Multiple textbox in form as multiple Records in Table

djossh

Registered User.
Local time
Today, 19:04
Joined
Oct 19, 2011
Messages
89
Hi, Newbie here, Hope someone can help me....

I have this multiple sets/groups of unbound textbox in form.. I want to save the values of the sets/groups of texbox in my table as new record based on per sets of textbox..

here's a sample..

(Sets/groups of Textbox in my form)

textbox1, textbox1A, textbox1B, textbox1C
textbox2, textbox2A, textbox2B, textbox2C
textbox3, textbox3A, textbox3B, textbox3C

I want to save the first set/group as record 1 then second set/group as record 2 and last set/group as record 3... that means.. everytime I click or save the values in my form to my table, it will generate 3 records everytime. I hope someone can help.. thanks
 
You could do something along the lines of;
Code:
Dim IntCount As Integer
Dim strSQL As String

IntCount = 1

While intCount < 4
strSQL = "INSERT INTO YourTableName ( YourFirstFieldName, YourSecondFieldName, YourThirdFieldName, YourFourFieldName ) " & _
         "SELECT [forms]![YourFormName]![textbox" & IntCount & "] AS Expr1, " & _
         "[forms]![YourFormName]![textbox" & IntCount & "A] AS Expr2, " & _
         "[forms]![YourFormName]![textbox" & IntCount & "B] AS Expr3, " & _
         "[forms]![YourFormName]![textbox" & IntCount & "C] AS Expr4;"

         DoCmd.RunSQL strSQL

        intCount = intCount + 1
Wend
This code assumes you will always have three groups of four text boxes.
 
...and named per your OP
 
You could do something along the lines of;
Code:
Dim IntCount As Integer
Dim strSQL As String
 
IntCount = 1
 
While intCount < 4
strSQL = "INSERT INTO YourTableName ( YourFirstFieldName, YourSecondFieldName, YourThirdFieldName, YourFourFieldName ) " & _
         "SELECT [forms]![YourFormName]![textbox" & IntCount & "] AS Expr1, " & _
         "[forms]![YourFormName]![textbox" & IntCount & "A] AS Expr2, " & _
         "[forms]![YourFormName]![textbox" & IntCount & "B] AS Expr3, " & _
         "[forms]![YourFormName]![textbox" & IntCount & "C] AS Expr4;"
 
         DoCmd.RunSQL strSQL
 
        intCount = intCount + 1
Wend
This code assumes you will always have three groups of four text boxes.

Thank you so much.. I really appreciate it... Keep up the good work! Thanks again..
 

Users who are viewing this thread

Back
Top Bottom