Closing and open Form whilst linking the correct record being open

C

Confused87

I want to close the open form when clicking away using the command button -
however, I want to open onto a linked record - where in the following code do
I do that?


Private Sub OpenAssetsBtn_Click()

On Error GoTo ErrHandler

DoCmd.OpenForm "frmAssets"
DoCmd.Close acForm, Me.Name

Exit Sub

ErrHandler:

MsgBox "Error in OpenAssetsBtn_Click( ) in " & Me.Name & " form." & _
vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear

End Sub

____________
OpenAssetsBtn = button
frmAssets = form to open

the linking is called
New ID 2
in the form I want to open and
associated member
in the form I am closing.

Does anyone know where I can get some basic info in how to build code, I've
been doing it in a very cut and paste way to date and would like a really
clear guide - any ideas?

Cheers
C
 
P

PieterLinden via AccessMonster.com

Confused87 said:
I want to close the open form when clicking away using the command button -
however, I want to open onto a linked record - where in the following code do
I do that?

Private Sub OpenAssetsBtn_Click()

On Error GoTo ErrHandler

DoCmd.OpenForm "frmAssets"
DoCmd.Close acForm, Me.Name

Exit Sub

ErrHandler:

MsgBox "Error in OpenAssetsBtn_Click( ) in " & Me.Name & " form." & _
vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear

End Sub

____________
OpenAssetsBtn = button
frmAssets = form to open

the linking is called
New ID 2
in the form I want to open and
associated member
in the form I am closing.

Does anyone know where I can get some basic info in how to build code, I've
been doing it in a very cut and paste way to date and would like a really
clear guide - any ideas?

Cheers
C

You're not filtering the second form when you open it. Pass the field the
two source tables have in common when you open the form... one of the last
arguments of the DoCmd.OpenForm method is the filter... just build a valid
WHERE clause, and away you go.
 
C

Confused87

Thanks PieterLinden, but unfortunatly my knowledge is VERY basic. Could you
give me some more detailed information or refer me to a good guide which will
tell me what all that means?

Many Thanks
C
 

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