Unanswered: Adding Data to Table Using Unbound Form
I have a small problem chich I am trying to fix.
I would like to add a new row to my database using an unbound form. The unbound form has 2 textboxes and 2 comboboxes(the sources are 2 separate tables related to the main table). I managed to build the SQL query in order to add the information but the problem is that every time the user hits the Save button a generic MS Access message comes up whether the user is sure he wants to add a new row to the specified table. Is is possible to substitute it with my own. Also underneath is my code, can somebody tell me whether I wrote it right and if there is a better way to do it.
Private Sub Command13_Click()
Dim strSQL As String
strSQL = "INSERT INTO tblUsers (ID, Password, System, Staff) VALUES(txtUsername, txtPassword, cmbSystem, cmbStaff)"
Well, if you're sure you want to use SQL to add the records to the table instead of ADO, just go to Tools-->Options, click on the Edit/Find tab, and under Confirm, uncheck Action queries. I have Access 2002 so that's the only layout I can confirm. The options windows may be different in other versions. Since an Append query is an action query, this should take care of your problem. I hope. :-)
Thank you DocX. It worked.
I am using SQL since I thought that it is the easiest and in fact...the only way. I am unfortunately not that proficient in Access so I do not know most of the functions. What does ADO involve? If you do not want to explain can you please point me into a good direction where I can read about it. Thank you
I guess I should've mentioned that this option will, indeed, turn off ALL prompts to ANY action queries.
Following the above coded options would be a safer bet if you just wanted to turn off the prompts for this addition alone. However, if you never want any action queries to prompt you, go for unchecking the confirm checkbox. That's my opinion and it only matters as much as you want it to.
As for recordset handling with ADO and ADOX, my reference is Access 2002 Developer's Handbook, which gives the basics. There's a plethora of resources out there including on the Internet, from basic to in-depth explanations. Anyone have any suggestions for web-based tutorials?