View Full Version : Data Write


MikeEller
01-30-2008, 08:13 AM
When does form data get written to a table?

I want to use the value from a textbox as openargs for another form. If I don't do a write to the table with SQL, then I get a NULL error on the getOpenArgs on the form. If I do do a write, then I get multiple occurrances of the record.

Thanks,
Mike

RuralGuy
01-30-2008, 10:41 AM
Just after the BeforeUpdate event of the form if that helps you.

MikeEller
01-30-2008, 11:45 AM
When I do the write, as follows:

DoCmd.GoToRecord acDataForm, "frmMain", acNewRec
sqlText = "INSERT INTO tblmain (controlnum) VALUES ('" & tskNum & "');"
DoCmd.RunSQL sqlText

This works fine

but then I do this:

strRecord = "SELECT * FROM tblmain WHERE controlnum = '" & tskNum & "'"
Me.RecordSource = strRecord

And I get an error message: Run Time Error 2001
You canceled the previous operation.

If I don't do this, then when I open the second form make some data selections and write that data to the corresponding record (identified by the form's openargs) the I have three new records added to the table.
I cannot figure out how it is doing this.

Mike

RuralGuy
01-30-2008, 12:24 PM
Don't change the RecordSource! Just do a Me.Requery.