Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / April 2008

Tip: Looking for answers? Try searching our database.

open form ubder conditions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
emma - 09 Apr 2008 09:57 GMT
Hi,

Ihave two forms, called Form1 and Form2.
Form1 contains Command1
Form2 contains combobox1 and combobox2

I want to open form2 using command1_click.
After opening me.combobox must be "3" and
me.combobox2 must be "5'.
The numbers "3"' and "5"are variabeles generated in form1.

Private Sub Command1_Click()
DoCmd.OpenForm ("form2")
'  with condition:
'  WHERE me.combobox  LIKE "3" AND me.combobox2 LIKE "5'
End Sub

Thanks,

Emma
Klatuu - 09 Apr 2008 14:59 GMT
Your post is confusing in that I don't see anything conditional about it.  If
they will always be 3  and  5, then in the Load event of form 2

   With Me
       .combobox1 = 3
       .combobox2 = 5
   End With

If that is not what you want, please clarify your question and we can help.
Signature

Dave Hargis, Microsoft Access MVP

> Hi,
>
[quoted text clipped - 16 lines]
>
> Emma
Linq Adams - 09 Apr 2008 16:41 GMT
Your code with the "Where"is actually looking for a record that already exits
where the comboboxes are already set to 3 and 5, not setting the values of
the comboboxes. If Dave's guess is incorrect, and the 3 and 5 were just
examples of what the two variables may be, something like this will work,
remembering that the variable values must be available to your Command1 sub:

In your Form1

Private Sub Command1_Click()
 DoCmd.OpenForm "Form2", , , , , , Variable1 & ";" & Variable2
End Sub

In your Form2

Private Sub Form_Open(Cancel As Integer)
 If Not IsNull(Me.OpenArgs) Then
   VarValues = Split(Me.OpenArgs, ";")
   Me.ComboBox1 = VarValues(0)
   Me.ComboBox2 = VarValues(1)
End If
End Sub

Signature

There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Klatuu - 09 Apr 2008 16:49 GMT
I considered including almost exactly what you propose, but didn't only
because the OP did not really make it clear.
Signature

Dave Hargis, Microsoft Access MVP

> Your code with the "Where"is actually looking for a record that already exits
> where the comboboxes are already set to 3 and 5, not setting the values of
[quoted text clipped - 17 lines]
>  End If
> End Sub
Albert D. Kallal - 09 Apr 2008 16:24 GMT
> I want to open form2 using command1_click.
> After opening me.combobox must be "3" and
> me.combobox2 must be "5'.
> The numbers "3"' and "5"are variabeles generated in form1.

docmd.OpenForm "form2"
forms!Form2.combobox = 3
forms!form2.combobox2 = 5

You don't mention what the actual vars are, but you would replace the 3 and
5 with the variable names in the above code.....

Signature

Albert D. Kallal    (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.