Code Only works first time!

B

Bob Vance

This code only works the first time I open the form, Do I need to add
something else to it?........Thanks Bob

Private Sub cmdEdit_Click()
On Error GoTo Err_cmddelete_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAccountStatus"

stLinkCriteria = "[BillID1]=" & Me![tbBillID1]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmddelete_Click:
Exit Sub

Err_cmddelete_Click:
'MsgBox Err.Description
Resume Next
End Sub
 
B

Bob Vance

Sorry should have explained better, yes the filter works the first time but
when I select another record it does not filter! Thanks Bob

Roger Carlson said:
As far as I can see, this is generic code that the Button Wizard creates.
Nothing more is needed.

What do you mean it only works the first time you open the form? Do you
mean it works only once after you open the form? If so, on subsequent
tries, does the Event fire but the code doesn't work, or that the Event
doesn't even fire?

Access 2007 is much more sensative to VBA security, so make sure you have
your database in a Trusted Location.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L



Bob Vance said:
This code only works the first time I open the form, Do I need to add
something else to it?........Thanks Bob

Private Sub cmdEdit_Click()
On Error GoTo Err_cmddelete_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAccountStatus"

stLinkCriteria = "[BillID1]=" & Me![tbBillID1]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmddelete_Click:
Exit Sub

Err_cmddelete_Click:
'MsgBox Err.Description
Resume Next
End Sub
 
B

Bob Vance

Thanks Guys worked it out, had to close the form and reopen it ;)
Private Sub cmdPaymentZero_Click()
On Error GoTo Err_Command326_Click

Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.Close acForm, "frmPaymentListZero"
stDocName = "FrmPaymentListZero"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command326_Click:
Exit Sub

Err_Command326_Click:
MsgBox Err.Description
Resume Exit_Command326_Click
End Sub
Bob Vance said:
Sorry should have explained better, yes the filter works the first time
but when I select another record it does not filter! Thanks Bob

Roger Carlson said:
As far as I can see, this is generic code that the Button Wizard creates.
Nothing more is needed.

What do you mean it only works the first time you open the form? Do you
mean it works only once after you open the form? If so, on subsequent
tries, does the Event fire but the code doesn't work, or that the Event
doesn't even fire?

Access 2007 is much more sensative to VBA security, so make sure you have
your database in a Trusted Location.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L



Bob Vance said:
This code only works the first time I open the form, Do I need to add
something else to it?........Thanks Bob

Private Sub cmdEdit_Click()
On Error GoTo Err_cmddelete_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAccountStatus"

stLinkCriteria = "[BillID1]=" & Me![tbBillID1]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmddelete_Click:
Exit Sub

Err_cmddelete_Click:
'MsgBox Err.Description
Resume Next
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