Record Modification trouble-Please Help

F

Freida

I have a form where the user puts information into a form that populates the
the tables. It almost works. The only trouble I am having is when a user
wants to modify a field. I used the following code

Private Sub SOURCE_CODE_Click()
If Not (IsNull(Forms![Allocation-AP].[Source_Code])) Then
If MsgBox("Do you want to modify this Record?", vbYesNo, "Modify Record?")
= vbYes Then
DoCmd.RepaintObject acForm, "Allocation-AP"
DoCmd.RunCommand acCmdRefresh
DoCmd.OpenQuery "Modify existing data", acViewNormal, acEdit
Else
DoCmd.RunCommand acCmdUndo
End If
End If
End Sub

This works fine, except for when I go to create a new record, then I get the
box asking me if I want to modify the data. But I am not sure how to fix
this. Any help would be greatly appreciated
 
J

John W. Vinson

This works fine, except for when I go to create a new record, then I get the
box asking me if I want to modify the data. But I am not sure how to fix
this. Any help would be greatly appreciated

Check to see if you're at the new record:

Private Sub SOURCE_CODE_Click()
If Not (IsNull(Forms![Allocation-AP].[Source_Code]) AND Not Me.NewRecord) Then
If MsgBox("Do you want to modify this Record?", vbYesNo, "Modify Record?")
= vbYes Then
DoCmd.RepaintObject acForm, "Allocation-AP"
DoCmd.RunCommand acCmdRefresh
DoCmd.OpenQuery "Modify existing data", acViewNormal, acEdit
Else
DoCmd.RunCommand acCmdUndo
End If
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top