yes no user promt

C

cmichaud

I have this in my afterupdate event for a box. If the user enters yes
i want to go to a new record on the same subform. If they enter no i
want to move to a different control on a different subform.

can you help. i am new.

here is my code.Please help

Private Sub AllergyID_AfterUpdate()
If MsgBox("Do you want to add another Allergy?", vbQuestion & vbYesNo)
= vbYes Then
DoCmd.GoToRecord , , acNewRec

Else
(this is what i dont know what to put)

End If
End Sub
 
D

Dirk Goldgar

I have this in my afterupdate event for a box. If the user enters yes
i want to go to a new record on the same subform. If they enter no i
want to move to a different control on a different subform.

can you help. i am new.

here is my code.Please help

Private Sub AllergyID_AfterUpdate()
If MsgBox("Do you want to add another Allergy?", vbQuestion & vbYesNo)
= vbYes Then
DoCmd.GoToRecord , , acNewRec

Else
(this is what i dont know what to put)

End If
End Sub

Where is this other subform? Is it a subform of the same form that
contains the subform with this code, so that the two subforms are
"siblings", as you might say? Supposing that the other subform control
(on the parent form) is named "sfOtherSubform", the code you need might
look like this:

Me.Parent!sfOtherSubform.SetFocus
 
C

cmichaud

There is a form with a tab control on it. One of the tabs has the
three subforms. I want to go from one subform to the next. The form
name is frmPersonal Info. The first subform is subfrmMemberAllergies.
The second subform is subfrmMemberMedicalConditions.

So can the code look like
Me.PersonalInfo!SubfrmMemberMedicalConditions.SetFocus

Where do i tell it what field i want it to start with. Which would be
MedicalConditionID of SubFrmMemberMedicalConditions.

Thanks!
 
D

Dirk Goldgar

There is a form with a tab control on it. One of the tabs has the
three subforms. I want to go from one subform to the next. The form
name is frmPersonal Info. The first subform is subfrmMemberAllergies.
The second subform is subfrmMemberMedicalConditions.

So can the code look like
Me.PersonalInfo!SubfrmMemberMedicalConditions.SetFocus

Not exactly. When I used the word "Parent", that was meant to be taken
literally -- it's a reference to the Parent property of the subform. So
use this:

Me.Parent!SubfrmMemberMedicalConditions.SetFocus
Where do i tell it what field i want it to start with. Which would be
MedicalConditionID of SubFrmMemberMedicalConditions.

You need a second SetFocus statement, to go along with the first one:


Me.Parent!SubfrmMemberMedicalConditions.Form!MedicalConditionID.SetFocus

Or you can get a tidier notation for the two statements by using the
With ... End With construction:

With Me.Parent!SubfrmMemberMedicalConditions
.SetFocus
.Form!MedicalConditionID.SetFocus
End With
 
C

cmichaud

Dirk

This is what i got

Private Sub AllergyID_AfterUpdate()
If MsgBox("Do you want to add another Allergy?", vbQuestion & vbYesNo)
= vbYes Then
DoCmd.GoToRecord , , acNewRec

Else
With Me.Parent!SubfrmMemberMedicalCondition
.SetFocus
.Form!MedicalConditionID.SetFocus
End With

End If
End Sub

When i hit no it is telling me MS access cant find the field
'subfrmmembermedicalcondition' referred to in your expression.

what do you think. is there somethng wrong with the was that subform
is implanted on the form. I am trying to move from subform to subform.

Argh!
 
D

Dirk Goldgar

Dirk

This is what i got

Private Sub AllergyID_AfterUpdate()
If MsgBox("Do you want to add another Allergy?", vbQuestion & vbYesNo)
= vbYes Then
DoCmd.GoToRecord , , acNewRec

Else
With Me.Parent!SubfrmMemberMedicalCondition
.SetFocus
.Form!MedicalConditionID.SetFocus
End With

End If
End Sub

When i hit no it is telling me MS access cant find the field
'subfrmmembermedicalcondition' referred to in your expression.

what do you think. is there somethng wrong with the was that subform
is implanted on the form.

It's quite possible that the name of the subform *control* on the main
form -- the control that displays the subform -- is not the same as the
name of the form object it's displaying (its "SourceObject"). Your
reference must use the name of the subform *control*. So check that
control to see if its name is something else, and then either change
that name or change the code to use that name in place of
"SubfrmMemberMedicalCondition".

If that's not the problem, we'll need to investigate further.
 
C

cmichaud

Maybe it is the pizza i just had for lunch slowing my mind...maybe not.

When i created the form i based it on tblPersonalInfo. I then inserted
a tab control. On page 2 of the tab control i dragged forms from the
form object box. This created my subforms on the tab. I dont see
where the *control* is and dont remember setting one. Where do i go to
check this reference.

thanks for your patience and help.
 
D

Dirk Goldgar

Maybe it is the pizza i just had for lunch slowing my mind...maybe
not.

When i created the form i based it on tblPersonalInfo. I then
inserted a tab control. On page 2 of the tab control i dragged forms
from the form object box. This created my subforms on the tab. I
dont see where the *control* is and dont remember setting one. Where
do i go to check this reference.

When you dropped those forms onto the tab page, Access created a
separate subform control for each of them, and set that control's
SourceObject property to the name of the form. The name of the control
will have been set to the Caption property of the form, if that property
wasn't blank, or else to the name of the form.

What you see represented on the tab page of the main form (in design
view) are the subform controls, and within each is the design view of
the form that is its SourceObject. If you click somewhere on the main
form, and then click *once* on one of those subform controls, what you
will have selected is the subform control itself. You'll see that the
borders of the control are highlighted. If you then click the
Properties button, the property sheet will show you the properties of
that control. The caption of the property sheet will state that this is
a "Subform/Subreport"

If you click a second time inside the subform control, you will now have
selected the control's SourceObject form or one of the controls on that
form, and the property sheet will reflect that fact. But what we are
interested now in are the properties of the subform control itself, so
don't click a second time. Click just once on the subform control, open
its property sheet, and check its Name property, which is displayed in
the property sheet's caption bar and in the Name property on the Other
tab of the property sheet.
 
C

cmichaud

Ok. I did that. This is the result.

source object = subfrmMemberMedicalCondition
Name = tblMemberMedicalCondition

do i change the name to subfrmmembermedicalcondition???

tks.
 

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