DoCmd Help

  • Thread starter Thread starter Stacy
  • Start date Start date
S

Stacy

I have a combo box that triggers another(popup)form based
on choices made by user. In order for a user to trigger
the second form, he/she would have to choose either 1 or 2
from the combo box. I have the following DoCmd written to
trigger the form but I need assistance on the WHERE
condition. Any help would be appreciated!

Private Sub OutDeath_AfterUpdate()
DoCmd.OpenForm "Treatment"
End Sub


Thank you!!
 
If OutDeath is your combo box, then try this:

If Me!OutDeath = 1 or Me!OutDeath = 2 then
DoCmd.OpenForm "Treatment"
End If
 
Thank you!! This worked!!
-----Original Message-----
If OutDeath is your combo box, then try this:

If Me!OutDeath = 1 or Me!OutDeath = 2 then
DoCmd.OpenForm "Treatment"
End If

--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX





.
 
If I wanted to use this procedure for several combo boxes
and make the "OutDeath" portion of this generic, how can I
do that?

Thank you!
 
Try this:

1. Insert the following Procedure in the code module of your form:

Public Sub OpenTreatment(ctl As String)

If Me(ctl) = 1 Or Me(ctl) = 2 Then
DoCmd.OpenForm "Treatment"
End If

End Sub

2. In the AfterUpdate event of each of the combo boxes that will be
evaluated for the value 1 or 2, insert the following:

Dim MyCtl As Control
Set MyCtl = Screen.ActiveControl

OpenTreatment MyCtl.Name

hth,
 
Thank you. I truly appreciate your help.

-----Original Message-----
Try this:

1. Insert the following Procedure in the code module of your form:

Public Sub OpenTreatment(ctl As String)

If Me(ctl) = 1 Or Me(ctl) = 2 Then
DoCmd.OpenForm "Treatment"
End If

End Sub

2. In the AfterUpdate event of each of the combo boxes that will be
evaluated for the value 1 or 2, insert the following:

Dim MyCtl As Control
Set MyCtl = Screen.ActiveControl

OpenTreatment MyCtl.Name

hth,
--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX





.
 
Cheryl,

If I want to prefill one of the text boxes in
my "Treatment" form when it pops up how can I do this?
I thought I would be able to use to OpenArgs parameter but
I'm not sure about this. (I'm not used to VB.. I usually
code in C/C++). Thanks again for your help!
 
If the Treatment form opens to a new record, you can use the Default Value
property of the TextBox. Otherwise, you could put the following in the Open
event of the Treatment form:

Me!MyTextBox = "whatever"

If that does not help, post back with more detail about the Treatment form
and what you want to do.
 

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

Similar Threads

run time error; can not write to object 1
trying to close a form 1
DoCmd help 1
Not in list warning 2
How to Write Code? 3
Not in list warning 1
MsgBox error 9
Cancel timer event if criteria not met 1

Back
Top