DoCmd.RunSQL combobox column

F

finster26

I am not sure what is wrong with the statement:

DoCmd.RunSQL "INSERT INTO CaseAddresses ( [Address] ) VALUES
(Forms![AddressManager].Form![cmbAddress]![Column(2)])", -1

I have a combo box and I am trying to take the value from column 2 of the
combobox and have it enter as a new record in the CaseAddresses table in
field Address. It adds a new record but it's blank in the Address field. I
have the correct column.
 
D

Douglas J. Steele

The reference to the control has to be outside of the quotes.

DoCmd.RunSQL "INSERT INTO CaseAddresses ( [Address] ) " & _
"VALUES ('" & Forms![AddressManager].Form![cmbAddress]![Column(2)] &
"')", -1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top