add data from a combo box

w0od0o

Registered User.
Local time
Today, 10:18
Joined
Jan 13, 2009
Messages
87
Hi,

i am trying to add the data from a combo box to a different table on the click of a button,

for example, im selecting a certain quote filtering through from client, location the quote number and i want to add a new record (when awarded the work) to contract unsing the quote ID (foreign key) when i click a button.

i can get it to add the data when selecting it from the combo box but if i select the wrong for example the reselect it creates 2 record so i want to have a button there before it adds the data.

Hope this makes sense

Thanks

W0od0o
 
A form should be used for adding data VIA controls. You shouldn't use a selection in a combo box to add data.

Unless you want to elaborate on your idea?
 
Hi,

i am trying to add the data from a combo box to a different table on the click of a button,

for example, im selecting a certain quote filtering through from client, location the quote number and i want to add a new record (when awarded the work) to contract unsing the quote ID (foreign key) when i click a button.

i can get it to add the data when selecting it from the combo box but if i select the wrong for example the reselect it creates 2 record so i want to have a button there before it adds the data.

Hope this makes sense

Thanks

W0od0o

On CommandButton Click Event enter the following code:

Code:
   On Error GoTo Err_Handler
 
    Dim strSQL As String
    Dim db As Database
    Set db = CurrentDb
 
    strSQL = "INSERT INTO YourTable (FieldName1, FieldName2, FieldName3)"
    strSQL = strSQL + "VALUES ("
    strSQL = strSQL + "'" & Me!ControlName1 & "', "
    strSQL = strSQL + "'" & Me!ControlName2 & "', "
    strSQL = strSQL + "'" & Me!ControlName3 & "' )"
 
    db.Execute (strSQL)
 
Err_Handler_Exit:
    Exit Sub
Err_Handler:
    MsgBox Err.Description
    Resume Err_Handler_Exit

Please change the control names and field names accordingly.
Khalid
 

Users who are viewing this thread

Back
Top Bottom