PDA

View Full Version : add record with data from form and VBA ??



bdsii
02-10-2011, 07:26 PM
I have looked around but cannot find a solution to my problem here. I can figure out a work around but would prefer to learn how to handle this correctly.

I want to add a new record through a form and when the user has completed all the fields they can click on the Add command button. When this happens I would like to add data to two fields not included on the form. I want to add the current date and also a status of "Ready" to another field. This would happen without user interaction but when the record is being added.

I have tried an update tablename and set field value but could not get the syntax correctly or something because I kept getting an error.

Can anyone provide code that would accomplish the above ? For this example let's say the table is TableName and the date field is AddDate and the status field is Status. Anyone have any ideas ?

I also want to add code to the command button that saves the record and then closes. I have that code that works but should I update the two fields before saving the record or use the save record command first and then update the two fields ?

Any help would be appreciated ! :-)

L@ja
02-11-2011, 05:46 PM
check it:
http://www.vbaexpress.com/forum/showpost.php?p=235716&postcount=24

bdsii
02-12-2011, 09:46 AM
Thanks L@ja but will that add the info from the form AND the direct data I want to add to the same record in that table ? It seems your code is creating a new record to add that data not adding it to the current record being added ??

Ideas ?

L@ja
02-12-2011, 09:55 AM
hi,
my code show how can you save any data to any tbl
you have to unbind your form(delete the form.datasource), and
after that you have a frm load code which fill your form,
and your second task: make a save btn with linked code...

if not clear this then I'll write you a examle(if I have a little freetime)
:work: