rs.update (1 Viewer)

Mechele

Registered User.
Local time
Today, 04:32
Joined
Jan 25, 2002
Messages
121
I'm using a form to determine if a record exist. If it doesn't then the program will open a form (TPAform) to add a record. If the record does exist, the program will open TPAFormUpdate (a form to update a record.)

Where should I put the following statement so that the information added or changed will be saved? rs.update


Private Sub TPACheck_Click()
Dim rs As Recordset
Dim db As Database
Dim strSQL3 As String

strSQL3 = "SELECT * FROM TPATable WHERE TPATable.ClientID = " & Me!UpdateTemp
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL3)
If rs.EOF And rs.BOF Then
DoCmd.Minimize
DoCmd.OpenForm "TPAForm"
rs.AddNew
[Forms]![TPAForm]![ClientID] = Me!UpdateTemp
Else
DoCmd.Minimize
DoCmd.OpenForm "TPAFormUpdate"
rs.Edit
End If
End Sub:confused:
 

jjturner

Registered User.
Local time
Today, 04:32
Joined
Sep 1, 2002
Messages
386
Stop the Press!

Not to make light of your situation, but in taking a look at the event procedure, you're opening the 'Add' form or 'Edit' form then immediately attempting to 'AddNew' or 'Edit' your recordset object before the user has had a chance to enter anything on those forms.

Presuming your 'Add' form ('TPAForm') has the same fields/controls as your 'Edit' form ('TPAFormUpdate'), it would be much more efficient if you just used 1 form to both 'Add' and 'Edit' records.

Lastly, if you do intend to launch a form which allows the user to add or edit, then just set the RecordSource for that form to your underlying table. Records in the table will then be automatically added or updated according to what the user enters.

Hope this helps!
John
 

Mechele

Registered User.
Local time
Today, 04:32
Joined
Jan 25, 2002
Messages
121
Thank you!:)
 

Users who are viewing this thread

Top Bottom