Open previous form from current form sub form

paulcraigdainty

Registered User.
Local time
Today, 21:16
Joined
Sep 25, 2004
Messages
74
I have a fault form which the user enters details of a fault. When the fault form is submitted the data is saved in the relevant table and the form is cleared so that the user can enter the next fault. On the fault form i have a subform which displays the faults previously entered by the user. I want the user to be able to click on an entry in the subform and open the orignal fault form and see the data that had been entered. How can i create this functionality??
 
Form

In the On Click Event of a field in the subform you can put some code like this:

******
Dim db As DAO.Database
Dim rst As DAO.Recordset

DoCmd.OpenForm "frmFault"

Set rst = Forms!frmFault.Recordset.Clone

rst.FindFirst "[FaultID] = " & Me.FaultID
Forms!frmFault.Bookmark = rst.Bookmark

******
Replace 'frmFault' with the actual name of the form and
'FaultID' with the name of the field you are using for a unique identifier
for each record.
 
Compile error msg

Hi, thanks for the advice. I have tried to implement the code however, when i click on the field to execute the on click event i receive the following compile error msg: User defined type not defined. I get the error on the first line of the code.
 
Code

Hmm.. may be a version problem.
Which version of Access are you using?

If you post the db (without sensitive data) I'll be happy to look at it. :)
 
sorry i didn't attach the .mdb, here it is. You will have to launch the database whilst the shift key is pressed down. Many thank
 

Attachments

Is the FaultID you use by any chance a text string?

If so, change this code line

Code:
rst.FindFirst "[FaultID] = " & Me.FaultID

by

Code:
rst.FindFirst "[FaultID] = '" & Me.FaultID &"'"

RV
 
No, im using an Autonumber in the field. I have tried the code though however i still can't get it to work.
 
Check your references (open VBA window, select Tools -> References from menu bar).
Check whether the Microsoft DAO reference has been ticked.
It should.

RV
 
Brilliant that works but.....

That's great it works now however....The field that the user double clicks to display the record is now populated with ##name? rather than the fault ref. I can't seem to work out how to get it to display the ref no
 

Users who are viewing this thread

Back
Top Bottom