A
Azhar
Hi..
I have searched a record, and displayed it "read only" on a form . Now I
wanted to have an edit command button on the form, i.e. by clicking it i may
be able to edit that record.
The code attached to the serch button is as under:
Private Sub Command14_Click()
On Error GoTo Err_Command14_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "view"
stLinkCriteria = "[Registration No]=" & "'" & Me![txtregno] & "'"
'Check txtregno for Null value or Nill Entry first.
If IsNull(Me![txtregno]) Or (Me![txtregno]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![txtregno].SetFocus
Else: DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
End If
Exit Sub
Exit_Command14_Click:
Exit Sub
Err_Command14_Click:
MsgBox Err.Description
Resume Exit_Command14_Click
End Sub
and the code which have placed with edit button on the form is as under:
kindly correct or replace it.
Private Sub Command85_Click()
On Error GoTo Err_Command85_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "view"
stLinkCriteria = "[Registration No]=" & "'" & Me![Registration No] & "'"
DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria, acFormEdit
Label51.Caption = "Edit Record"
Exit_Command85_Click:
Exit Sub
Err_Command85_Click:
MsgBox Err.Description
Resume Exit_Command85_Click
End Sub
I have searched a record, and displayed it "read only" on a form . Now I
wanted to have an edit command button on the form, i.e. by clicking it i may
be able to edit that record.
The code attached to the serch button is as under:
Private Sub Command14_Click()
On Error GoTo Err_Command14_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "view"
stLinkCriteria = "[Registration No]=" & "'" & Me![txtregno] & "'"
'Check txtregno for Null value or Nill Entry first.
If IsNull(Me![txtregno]) Or (Me![txtregno]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![txtregno].SetFocus
Else: DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
End If
Exit Sub
Exit_Command14_Click:
Exit Sub
Err_Command14_Click:
MsgBox Err.Description
Resume Exit_Command14_Click
End Sub
and the code which have placed with edit button on the form is as under:
kindly correct or replace it.
Private Sub Command85_Click()
On Error GoTo Err_Command85_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "view"
stLinkCriteria = "[Registration No]=" & "'" & Me![Registration No] & "'"
DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria, acFormEdit
Label51.Caption = "Edit Record"
Exit_Command85_Click:
Exit Sub
Err_Command85_Click:
MsgBox Err.Description
Resume Exit_Command85_Click
End Sub