Code error when opening a form

B

Bob07790

Hi I have used this code in Access 2003 and it works with no errors in Access
2007 I get the following appear, the Find Box and the Enter Parameter Value
Box. By clicking ok in the Parameter value box without entering a value the
code continues to open the form on the correct record and the Find box
closes. How do I stop this happening?

Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
stDocName = "frmHASABIDetails"

stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria


Thanks Bob
 
S

Stuart McCall

Bob07790 said:
Hi I have used this code in Access 2003 and it works with no errors in
Access
2007 I get the following appear, the Find Box and the Enter Parameter
Value
Box. By clicking ok in the Parameter value box without entering a value
the
code continues to open the form on the correct record and the Find box
closes. How do I stop this happening?

Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
stDocName = "frmHASABIDetails"

stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria


Thanks Bob

That looks like the code was originally generated by the wizard, which MS
refuses to update for some reason. The line:

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

is an Access 2000 command, for goodness sake.

Try replacing that line with:

Me.Dirty = False

Also check to see if "[CustomerID]=" & Me![CustomerID] is correct (ie there
is a field called CustomerID and the form contains a control called
CustomerID).
Otherwise it should work fine.
 
B

Bob07790

Stuart

That now works fine, thanks for your help.

Bob

Stuart McCall said:
Bob07790 said:
Hi I have used this code in Access 2003 and it works with no errors in
Access
2007 I get the following appear, the Find Box and the Enter Parameter
Value
Box. By clicking ok in the Parameter value box without entering a value
the
code continues to open the form on the correct record and the Find box
closes. How do I stop this happening?

Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
stDocName = "frmHASABIDetails"

stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria


Thanks Bob

That looks like the code was originally generated by the wizard, which MS
refuses to update for some reason. The line:

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

is an Access 2000 command, for goodness sake.

Try replacing that line with:

Me.Dirty = False

Also check to see if "[CustomerID]=" & Me![CustomerID] is correct (ie there
is a field called CustomerID and the form contains a control called
CustomerID).
Otherwise it should work fine.


.
 

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