Combobox: adding an entry to the "to do list" table

  • Thread starter Thread starter jake
  • Start date Start date
J

jake

I have a combobox named [cemetery] on a main form. I want my[cemetery]
combobox to create an entry in another table called the the "ToDoList"
table. In this case, the entry would be "Contact **** Gravedigger
608-339-1212" in the "to do list"

How do I do this?
Thank you, Jake
 
Hi,


CurrentDb.Execute "INSERT INTO ToDoList( [to do list] ) VALUES( 'Contact
*** Gravedigger 608-339-1212') ;" , dbFailOnError




The syntax is:

INSERT INTO tableName( listOfFields) VALUES( listOfValues)


where the values have to got the delimiters, if required.


Hoping it may help,
Vanderghast, Access MVP
 
Thank you Michel for your help,
2 Questions...

1) I need to INSERT 3 items for the 2nd Table, what would the proper
syntax be?

2) Those Items will be the CaseID, and the 2nd and 3rd, columns from
the combo box - what is the proper syntax for that?

Thanks! Jake
 
Hi,


The supported syntax, for the actual version, only allows ONE record at
a time (repeat the statement for multiple records), but the record may fill
many fields:


CurrentDb.Execute "INSERT INTO myTable( f1, f2, f3) VALUES(v1, v2, v3)
", dbFailOnError


would insert the numerical values v1, v2, and v3, under the fields f1, f2
and f3 respectively.


CurrentDb.Execute "INSERT INTO myTable(f1, f2, f3) VALUES(" &
Me.ComboBox0.Column(0) & ", " & Me.ComboBox0.Column(1) & ", ' " &
Me.ComboBox0.Column(2) & " ' " ), dbFailOnError



where Column(0) and Column(1) are numerical and Column(2) alphanumerical (I
added the ' each side of it, with extra spaces... TO BE REMOVED... I add
space only for readability). Note that you count the column from 0 and you
count them even if they are not visible.


Hoping it may help,
Vanderghast, Access MVP
 
Back
Top