How to update form text fields to table?

  • Thread starter Thread starter jenScott
  • Start date Start date
J

jenScott

Guest
hello,

I have a form called "MailShots" that contains three text fields to be filled in by the user. The user can then click a command button, I want this to update the first record in a table called "MailShots".

Have tried several different things but cannot get the table to update.

Please help.

Jen
 
Try the following on a command button click event

Dim rst As Recordset

Set rst = CurrentDb.OpenRecordset("SELECT * FROM mailshots", dbOpenDynaset)


rst.MoveFirst
rst!TableFieldName = FormFieldName
rst!TableField2Name = FormField2Name 'etc etc
rst.Update
rst.Close

Just subsitute the names to you requirements

Dave
 
Thanks for that dave.

I have entered the code and I am getting an "invalid argument" error on the following line

Set rst = CurrentDb.OpenRecordset("SELECT * FROM MailShots", dbOpenDynaset)

I am new to database programming so I'm not sure what I should be looking for. Could you help?

Jen
 
Jen

That line of code looks ok to me. The only thing that comes to mind is that you need to define 'rst' eg

Dim rst as Recordset

Shay :cool:
 
You may have to check your references in the VB tools. I think you need to register DOA 3.6 object library
 

Attachments

Users who are viewing this thread

Back
Top Bottom