Form

E

Emma

Hi I have a form with housing status etc.. it's suppose to pop up and show
the information for the client from the first screen. Unfortunatley I can't
seem to get Child and Master fields and when I use the wizard the left form
is blank. Can anyone give me a suggestion of how to relate the 2 forms
together using Client ID?
 
E

Emma

I added the following to the button code and it works fine:
Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.RunCommand acCmdSaveRecord

stDocName = "Housing Form Outter"
stLinkCriteria = "[Client ID]=" & Me![Client ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
K

Ken Sheridan

That's fine for opening the second form. To keep it in sync with the first
form if the user moves to a different client record then also put the
following code in the first form's Current event procedure:

Const FORM2NOTOPEN = 2450
Dim frm As Form

On Error Resume Next
Set frm = Forms("Housing Form Outter")

Select Case Err.Number
Case 0
' no error so filter form to
' current Client ID in this form
frm.Filter = "[Client ID] = " & Nz(Me.[Client ID], 0)
frm.FilterOn = True
Case FORM2NOTOPEN
' anticipated error so do nothing
Case Else
' unknown error
MsgBox Err.Description, vbExclamation, "Error"
End Select

Alternatively open the second form in dialogue mode, which will force the
user to close it before returning to the first form. To do this change the
final line of your code to:

DoCmd.OpenForm stDocName, _
WhereCondition:=strLinkCriteria, _
Windowmode:=acDialog

Ken Sheridan
Stafford, England

Emma said:
I added the following to the button code and it works fine:
Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.RunCommand acCmdSaveRecord

stDocName = "Housing Form Outter"
stLinkCriteria = "[Client ID]=" & Me![Client ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Emma said:
Hi I have a form with housing status etc.. it's suppose to pop up and show
the information for the client from the first screen. Unfortunatley I can't
seem to get Child and Master fields and when I use the wizard the left form
is blank. Can anyone give me a suggestion of how to relate the 2 forms
together using Client ID?
 
E

Emma

Thanks Ken seems to be working

Ken Sheridan said:
That's fine for opening the second form. To keep it in sync with the first
form if the user moves to a different client record then also put the
following code in the first form's Current event procedure:

Const FORM2NOTOPEN = 2450
Dim frm As Form

On Error Resume Next
Set frm = Forms("Housing Form Outter")

Select Case Err.Number
Case 0
' no error so filter form to
' current Client ID in this form
frm.Filter = "[Client ID] = " & Nz(Me.[Client ID], 0)
frm.FilterOn = True
Case FORM2NOTOPEN
' anticipated error so do nothing
Case Else
' unknown error
MsgBox Err.Description, vbExclamation, "Error"
End Select

Alternatively open the second form in dialogue mode, which will force the
user to close it before returning to the first form. To do this change the
final line of your code to:

DoCmd.OpenForm stDocName, _
WhereCondition:=strLinkCriteria, _
Windowmode:=acDialog

Ken Sheridan
Stafford, England

Emma said:
I added the following to the button code and it works fine:
Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.RunCommand acCmdSaveRecord

stDocName = "Housing Form Outter"
stLinkCriteria = "[Client ID]=" & Me![Client ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Emma said:
Hi I have a form with housing status etc.. it's suppose to pop up and show
the information for the client from the first screen. Unfortunatley I can't
seem to get Child and Master fields and when I use the wizard the left form
is blank. Can anyone give me a suggestion of how to relate the 2 forms
together using Client ID?
 

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