GoTo Record Not Working, Type Mismatch

G

Guest

Hello,

Can someone please tell me why my code isn't working. I have a subform
within a main form. When the user wants to edit existing data, they click on
the Edit button, where I have a dialog form popping up asking for the user
name and current date. This works fine. I have the below listed code
attached to the OK button, which is not working.

Can someome help me?

Thanks.

Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmADD_LEAK_SUBFORM"

stLinkCriteria = "[LEAKID]=" & "'" & Me![LEAKID] & "'"

DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, Me.Name
DoCmd.GoToRecord stDocName, , , stLinkCriteria

Exit_cmdOK_Click:
Exit Sub

Err_cmdOK_Click:
MsgBox Err.Description
Resume Exit_cmdOK_Click

End Sub
 
D

DS

Trini said:
Hello,

Can someone please tell me why my code isn't working. I have a subform
within a main form. When the user wants to edit existing data, they click on
the Edit button, where I have a dialog form popping up asking for the user
name and current date. This works fine. I have the below listed code
attached to the OK button, which is not working.

Can someome help me?

Thanks.

Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmADD_LEAK_SUBFORM"

stLinkCriteria = "[LEAKID]=" & "'" & Me![LEAKID] & "'"

DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, Me.Name
DoCmd.GoToRecord stDocName, , , stLinkCriteria

Exit_cmdOK_Click:
Exit Sub

Err_cmdOK_Click:
MsgBox Err.Description
Resume Exit_cmdOK_Click

End Sub
Try this


stLinkCriteria = "[LEAKID]=" & "" & Me![LEAKID] & ""

DS
 
G

Guest

DS,

Sorry, that didn't work, still get type mismatch. Any other suggestions.

Thanks

DS said:
Trini said:
Hello,

Can someone please tell me why my code isn't working. I have a subform
within a main form. When the user wants to edit existing data, they click on
the Edit button, where I have a dialog form popping up asking for the user
name and current date. This works fine. I have the below listed code
attached to the OK button, which is not working.

Can someome help me?

Thanks.

Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmADD_LEAK_SUBFORM"

stLinkCriteria = "[LEAKID]=" & "'" & Me![LEAKID] & "'"

DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, Me.Name
DoCmd.GoToRecord stDocName, , , stLinkCriteria

Exit_cmdOK_Click:
Exit Sub

Err_cmdOK_Click:
MsgBox Err.Description
Resume Exit_cmdOK_Click

End Sub
Try this


stLinkCriteria = "[LEAKID]=" & "" & Me![LEAKID] & ""

DS
 

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