FindRecord Error

G

Guest

Hi guys,

Getting very annoyed with this one. I have previously successfully used code
behind a Close button on a single record form to take me back to the
appropriate record on a list. Code used the FindRecord command to link
between the two forms e.g.

Forms![Employee List].Requery
DoCmd.OpenForm ("Employee List")
Forms![Employee List]![EmployeeID].Visible = True
DoCmd.GoToControl "EmployeeID"
DoCmd.FindRecord Forms![Employee Details]![EmployeeID], acEntire, ,
, , acCurrent
DoCmd.GoToControl "Employee Name"
Forms![Employee List]![EmployeeID].Visible = False

This code works well. So I transferred and modified the code to work in
another database - or so I thought. Here's the modified code:

Forms![CAN6].Requery
DoCmd.OpenForm ("CAN6")
Forms![CAN6]![CANDIDATEID].Visible = True
Forms![CAN6]![CANDIDATEID].SetFocus
DoCmd.FindRecord Forms![CAN2 INPUT]![CANDIDATEID], acEntire, , , ,
acCurrent
Forms![CAN6]!cmdClose.SetFocus
Forms![CAN6]![CANDIDATEID].Visible = False

This code generates the 2162 error - 'A macro set to one of the current
field properties failed because of an error in a FindRecord action argument'.
I have compared field properties until I'm going blind. Any ideas why the
latter code won't work?

TIA

Andrew
 
W

Wayne Morgan

Is the form [CAN2 INPUT] open when you run this? If so, then I would look
for a spelling error in the name of the form or control. Double check that
the actual names of the report and control are what you have typed. Also,
check to see if the data type of the control is the same as the data type of
the control on the form you are searching.
 
G

Guest

Thanks Wayne,

Yes, CAN2 INPUT is open, and I've checked for spelling errors. The data type
should be same, but I will check on that.

thanks

Andrew

Wayne Morgan said:
Is the form [CAN2 INPUT] open when you run this? If so, then I would look
for a spelling error in the name of the form or control. Double check that
the actual names of the report and control are what you have typed. Also,
check to see if the data type of the control is the same as the data type of
the control on the form you are searching.

--
Wayne Morgan
MS Access MVP


Dinsdale said:
Hi guys,

Getting very annoyed with this one. I have previously successfully used
code
behind a Close button on a single record form to take me back to the
appropriate record on a list. Code used the FindRecord command to link
between the two forms e.g.

Forms![Employee List].Requery
DoCmd.OpenForm ("Employee List")
Forms![Employee List]![EmployeeID].Visible = True
DoCmd.GoToControl "EmployeeID"
DoCmd.FindRecord Forms![Employee Details]![EmployeeID], acEntire, ,
, , acCurrent
DoCmd.GoToControl "Employee Name"
Forms![Employee List]![EmployeeID].Visible = False

This code works well. So I transferred and modified the code to work in
another database - or so I thought. Here's the modified code:

Forms![CAN6].Requery
DoCmd.OpenForm ("CAN6")
Forms![CAN6]![CANDIDATEID].Visible = True
Forms![CAN6]![CANDIDATEID].SetFocus
DoCmd.FindRecord Forms![CAN2 INPUT]![CANDIDATEID], acEntire, , , ,
acCurrent
Forms![CAN6]!cmdClose.SetFocus
Forms![CAN6]![CANDIDATEID].Visible = False

This code generates the 2162 error - 'A macro set to one of the current
field properties failed because of an error in a FindRecord action
argument'.
I have compared field properties until I'm going blind. Any ideas why the
latter code won't work?

TIA

Andrew
 

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

Similar Threads


Top