Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iif query statements to show forms

Status
Not open for further replies.

withoutaclue

Programmer
Aug 28, 2002
31
0
0
GB
Hi,
Im trying to create a query that will allow a user to enter a number, then if the number is greater than 10, show form 1, else show form2,

I have tried serveal codes, but it dosnt seem to like showing forms,

Does any one have any ideas,

Perhaps code can be written in a module?


Any suggestions would be great,
 
Maybe something like this (attached to a command button):

If InputBox("Enter a number") > 10 Then
DoCmd.OpenForm "YourForm1", acNormal
Else: DoCmd.OpenForm "YourForm2", acNormal
End If
 
That looks good, but it cant run of a form,

I have tried to crete a macro.

what i tried doing was to make a table based on what number the user enters (using make table query), then say only open form 1 based on the condidtion,

therefore macro read,s
Run query (this will place the users requed condion in to a filde)
open form 1, if filde 1 is > 10
open form 2, if filde 1 is < 9

however it still doent work as it opens both forms still


 
I have a button with this code that opens a different form based on another field on the form. I am sure you can get this to work for you:

Dim DocName As String
Dim LinkCriteria As String

If (Me![Department] = &quot;LAN GROUP&quot; Then
DocName = &quot;LAN Group Problems&quot;
Else
DocName = &quot;Problem&quot;

End If

DoCmd.OpenForm DocName, , , LinkCriteria
End Sub
 
function openformvar()
docmd.openform iif(InputBox(&quot;Enter a number&quot;) >10,&quot;form1&quot;,&quot;form2&quot;)
end function


create a macro
action=runcode
functionname=openformvar
 
that is really good and works like a treat and many thanks, but if i want to carry this forwar to say,

iff all the numbers in table1 filde 2 are below 10 show form1, else show form 2,

rather than getting the number from a promt

any suggestions??

 
function openformvar()
docmd.openform iif(dcount(&quot;*&quot;,&quot;tablename&quot;,&quot;fieldname>=10&quot;)=0,&quot;form1&quot;,&quot;form2&quot;)
end function
 
pwise, you are a star, no you are a super star, it works really well

Thank you so much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top