How can i add new records using DAO without making it confusing for the user?
Printable View
How can i add new records using DAO without making it confusing for the user?
Could you be a little more specific about what you want to let the end-user do? And/or define what it is about your current method that you understand is confusing. If you know the table, fields you intend letting the end-user insert, it's one thing; but if you are trying to allow the end-user to input SQL directly, it's another. With better def, I would be happy to give you my two cents worth :)
i know the fields and the table all that the end user has to do is enter the info. See thread http://forums.vb-world.net/showthrea...threadid=23036 for specifics
Sorry for the delay in responding, I got sidetracked.
It doesn't have to be much more exotic than something like this:
* pesky smiley faces, always forget to uncheck that box...Code:Sub AddNewRec_Click()
Dim SQL$, db as database
On Error Goto Oops
' when textbox values are error free
SQL$ = "INSERT <table_name>(<field1_name>, <field2_name>)VALUES('" & tb1_str & "', " tb2_int & ")"
Set db = OpenDatabase(<yourdatabase>)
db.execute SQL$
Set db = Nothing
' refresh supporting data form/object, as necessary, to show new data
' since end-user "sees" none of this, maybe add msgbox saying life is good
Exit Sub
Oops:
' maybe say the wheels flew off..
End Sub
And my SERIOUS headspace-timing being out of sync isn't helping either...
[Edited by Mongo on 07-16-2000 at 01:35 AM]
:)
in the line SQL$ etc..where it says tb1_str and tb2_int can i put text boxes eg txtband.text instead?
Yes. Sorry I got too short in my shorthand naming. I was trying to imply a textbox.text value that is supposed to be a string with tb1_str (note the extra tick marks on each side) and an integer datatype with tb2_int.
:):):):):):):):):)
:grin:
Thank you...
um the values weren't entered into the TABLE.
do i need the field names in brackets after the table name in the SQL line?
Jimminey Cricket, I am running on empty. Yes! When you are not including ALL table def fields in your insert or they are out of order, you must specify the field names.
And I meant the <> as generic signifiers, you DO NOT include them.
INSERT table_name(fieldA_name,fieldB_name)VALUES("IF DOPE USE ODD", 1)
[Edited by Mongo on 07-16-2000 at 01:37 AM]