Check Box

  • Thread starter Thread starter Khalil Handal
  • Start date Start date
K

Khalil Handal

Form2 saves it's own data.

Khalil

Graham R Seach said:
Khalil,

It depends on what you want to do with Form2. Do you want to return some
data to Form1 from Form2, or does Form2 save its own data? How does Form2
associate itself with the data from Form1?

Private Sub chkCheckBox_AfterUpdate()
If Me!chkCheckBox = True Then
'Open the form, either using DoCmdOpenForm ...
' or by subclassing Form2
End If
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
(Currently in Japan)
 
Here's a snippet I use on a form with a checkbox. Substitute your field
names.

Private Sub ynGift_AfterUpdate()

If Me.ynGift = "-1" Then
Me.memGiftDescription.Visible = True
Me.memNotesGift.Visible = True

Else

Me.memGiftDescription.Visible = False
Me.memNotesGift.Visible = False

End If

End Sub
 
Hi,
Form1 has a checkBox if ticked it means the person is married.
I want to do this:
When the checkBox is ticked a popup form opens Form2 that has several fields
about the spouse. How do I write the code for this?

Thank in advance for the help.

Khalil
 
Khalil,

It depends on what you want to do with Form2. Do you want to return some
data to Form1 from Form2, or does Form2 save its own data? How does Form2
associate itself with the data from Form1?

Private Sub chkCheckBox_AfterUpdate()
If Me!chkCheckBox = True Then
'Open the form, either using DoCmdOpenForm ...
' or by subclassing Form2
End If
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
(Currently in Japan)
 
Hi,
Form1 has a checkBox if ticked it means the person is married.
I want to do this:
When the checkBox is ticked a popup form opens Form2 that has several fields
about the spouse. How do I write the code for this?

Thank in advance for the help.

Khalil

Code the Check Box AfterUpdate event:
If Me![CheckBoxName] = -1 Then
DoCmd.OpenForm "Form2", , , , , acDialog
End If

Note: there are no " surrounding -1, as it is a number value, not
text.
 
i created a macro that opens the form afterupdate. should be straightfoward.

sam
 
Khalil,

In that case, it is as simple as shown below. Note that the associate the
record on Form2 with that on Form1, you need to pass Form1's primary key.
You can do that either by passing the PK (PersonID) in the OpenForm call, or
by using OpenArgs.

Private Sub chkCheckBox_AfterUpdate()
If (Me!chkCheckBox = True) Then
'Open Form2 and pass its PK via the WHERE clause
DoCmd.OpenForm "Form2", , , "[PersonID] = " & Me!txtPersonID

'Open the form and pass the PK via OpenArgs
DoCmd.OpenForm "Form2", , , , , , Me!txtPersonID
'If you take this option, you need code in Form2's Open event to
handle the argument
End If
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
(Currently in Japan)
---------------------------
 

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

Back
Top