Re: updating to a table
From: Rick Brandt (rickbrandt2_at_hotmail.com)
Date: 02/17/05
- Next message: Brendan Reynolds: "Re: Show lists in combo boxes"
- Previous message: anonymous_at_discussions.microsoft.com: "display record in form then, .addnew"
- In reply to: Jimenda: "updating to a table"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 17 Feb 2005 06:47:09 -0600
"Jimenda" <Jimenda@discussions.microsoft.com> wrote in message
news:F20BCE45-85A4-48E8-A4A2-7B06871ABABB@microsoft.com...
>I have a form that has 7 combo boxes, I would like to be able to make a
> selection in each box (if no selection made, then default or null), and then
> click on a button and have the selected items in each combo box to update/add
> 7 separate fields on a new line of a separate table. If anyone can help I
> would appreciate it. I already have the combos setup and can select a value
> in each combo. I am just not sure how to have a button cause all of the info
> to update a table.
> --
> Thank You & God Bless,
>
> Jimenda
The basic method is...
dim SQL as string
SQL = "INSERT INTO TableName " & _
"(Field1, Field2, Field3, etc...) " & _
"VALUES(" & Me.NumericComboBox & ", '" & _
"Me.TextComboBox & "', #" & _
"Me.DateComboBox & "#, etc...)"
Debug.Print SQL
'CurrentDB.Execute SQL, dbFailOnError
The challenge is in getting a string built up that results in a valid SQL
statement with all the proper delimiters, spaces, and If-then handling to
account for the Null values you want if a ComboBox is left blank.
That is why I include the Debug.Print line and have the execute statement
commented out. What you should do is tweak your code, try the code and then
examine the SQL string that is sent to the immediate window. This can be
examined to see if it is structured as you expected and can even be pasted into
a query to see if it has any errors and works as expected.
Once you have the code creating a correct statement you can comment out the
Debug.Print line and remove the comment from the execute line.
-- I don't check the Email account attached to this message. Send instead to... RBrandt at Hunter dot com
- Next message: Brendan Reynolds: "Re: Show lists in combo boxes"
- Previous message: anonymous_at_discussions.microsoft.com: "display record in form then, .addnew"
- In reply to: Jimenda: "updating to a table"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|