Open form and display current record

  • Thread starter Thread starter dficks
  • Start date Start date
D

dficks

Guest
Hi! I am trying to set up a button on a "list view" (or continuous) Access form that will appear next to a record and when clicked open up that same record in another form. The first form just displays some prelimenary data (First Name, Last Name, ID) and the button would take the user to the complete data entry form. I actually had this set up and working but had some different problems with the database and had to delete the button. Now I can't remember how I did this before...

I have tried building a Macro but can't seem to get past just opening the form. Any help would be appreciated!:confused:
 
I did this recently on a Helpdesk database. What I did was this -

On the current form, with the datasheet list or continuous form, get into the design of the subform or the wherever the list fields are displayed.
In the leftmost field open the OnClick property of the field and use the following code -



DoCmd.OpenForm "Form2",,"[Field1]=Forms!Form1!Field1"


if the list is a continuous form or,



DoCmd.OpenForm "Form2",,"[Field1]=Forms!Form1!Form2.Form.Field1"



Form1 = the name of your first form
Form2 = the name of your second form
Field1 = the lefthand filedname in the list on form1
Field2 = the matching field in the fields on the second form.

When the user clicks on the leftmost field, the second form opens at the correct record ready for action.

Field1 should be a unique value field (primary field) so that there is no ambiguity in the selection of the record.

If you want you can put an instruction on the form1 advising the user how to select the record for action. Saves the need for buttons, too.

That's it...

Dave E
 
Still not quite there ...

Hi, Dave. Thanks for the help, and I like the idea of doing this without a button. I tried the code you suggested but I am still not quite there. I placed it right in the "on click" property area of the leftmost field (ID). Was that the right place, because now I am getting a message (when I click the field) that says it can't find the macro Group DoCmd and goes on to say the Macro (or Macro) group doesn't exist or hasn't been saved. Any advice?

Dave F
 
Last edited:
I think you have left a reference to the macro somewhere where there shouldn't be one.

The code I refered to should go in the AFTERUPDATE property by clicking in the property, then on the 3 dots (...) that appear on the righthand end of the line and select Code Builder.

When the Code Builder screen opens, the cursor will be flashing in the place to put the code.

This isn't a macro, it's code so remove any reference to a macro in that property.

I hope this helps.

Dave Eyley
 
now I am getting a message (when I click the field) that says it can't find the macro Group DoCmd and goes on to say the Macro (or Macro) group doesn't exist or hasn't been saved.

I had the same problem once. You may have accidentally typed spaces in one of your form properties. If there are only spaces in one of the properties (such as AfterUpdate or OnActivate), this message may go away if you delete the spaces.

Hope this helps.
 
As a matter of interest, where did you put that bit of code?
Did you go into the Code Builder, or Macro facility?

Dave E
 

Users who are viewing this thread

Back
Top Bottom