Closing down a from whilst opening another form diplaying specific details (1 Viewer)

Javelin

The Backpacker
Local time
Today, 14:20
Joined
Mar 14, 2003
Messages
12
Can someone please help?

I have a database where the users can view all the records, via a form, in read-only format. Should the user wish to change any details at all on a particular record - they are forced to complete an audit trail first.

All this simply means is that at the bottom of each record (form) there is a link to the audit trail - this link was created using the command wizard to select the specific record. This is the code that is produces;

Private Sub Command51_Click()
On Error GoTo Err_Command51_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Amend Risk"

stLinkCriteria = "[Risk No]=" & "'" & Me![Ref No] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command51_Click:
Exit Sub

Err_Command51_Click:
MsgBox Err.Description
Resume Exit_Command51_Click

End Sub

My problem is that I want the form the user is leaving (i.e. the read-only record form) to close once the command link is activated to open the audit form. What code do I need to enter?

Also; when I open the audit form it still retains the information from the last person to complete the form - How can I/ or what code do I need to make sure the form opens with all the fields blank?

Thanks

Jav
 

jonesy

Registered User.
Local time
Today, 14:20
Joined
Jan 23, 2003
Messages
17
I'm not very good at the code side of it, but couldn't you do this with a macro. Create a macro that closes the form, then opens the audit form in Add data mode. Then assign the macro to the on click of your audit form button.

If this isn't what you're looking for i'm sure someone else can help you with the code.
 
R

Rich

Guest
Private Sub Command51_Click()
On Error GoTo Err_Command51_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Amend Risk"

stLinkCriteria = "[Risk No]=" & "'" & Me![Ref No] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close "YourFormNameHere"
Exit_Command51_Click:
Exit Sub

Err_Command51_Click:
MsgBox Err.Description
Resume Exit_Command51_Click

End Sub
 

Javelin

The Backpacker
Local time
Today, 14:20
Joined
Mar 14, 2003
Messages
12
Thanks Rich

Can you help me regarding my second problem;

How do I make get the audit trail form to open in add mode (in other words - all the fields blank) through VBA? - At the moment the fields retain their previous input.

Jav
 

Users who are viewing this thread

Top Bottom