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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie...Restrict Data that does not meet all Query Criteria?

Status
Not open for further replies.

iteach2

Technical User
Sep 16, 2001
120
US
Thank you all for your help, as a newbie i have done more with my DB than i ever would have without you alls-)

I have a popup form where you enter

StartDate:_________
Enddate:___________
Type:(hardware or software)
Site:WW or RR



My query looks like this:

SELECT tblChange.Type, tblChange.[ChangeCtrl#], tblChange.StartDate, tblChange.EndDate, tblChange.Status, tblChange.Site, tblChange.Description
FROM tblChange
WHERE (((tblChange.StartDate) Between [Forms]![hardsoftpopup]![txtStartDate] And [Forms]![hardsoftpopup]![txtEndDate]) AND ((tblChange.Site)=[Forms]![hardsoftpopup]![cboSite]) AND (([Forms]![hardsoftpopup]![cboType])<>False));

My execute button on popupform looks like this:

Private Sub cmdOK_Click()
If IsNull(Me!txtStartDate) Then
MsgBox &quot;Hey! Enter a Start Date.&quot;
Me!txtStartDate.SetFocus
ElseIf IsNull(Me.txtEndDate) Then
MsgBox &quot;Hey! Enter an End Date.&quot;
Me!txtEndDate.SetFocus
ElseIf IsNull(Me.cboType) Then
MsgBox &quot;Hey! Enter Type.&quot;
Me!cboType.SetFocus
ElseIf IsNull(Me.cboSite) Then
MsgBox &quot;Hey! Enter Site Name.&quot;
Me!cboType.SetFocus

Else
DoCmd.OpenReport &quot; rptHardSoft&quot;, acPreview
DoCmd.Close acForm, Me.Name
End If
End Sub

As you can see the query will check a specific date range
site name and type of update(either hardware or software).


Everything works fine,&quot;but&quot; when i do

startdate: 09/22
enddate: 09/24
Site:ww
Type: software

I get:


software 09/22 09/24

software 09/22 09/24

hardware 09/22 09/24


I don't know how to fix its-)

It look like the dates are overiding the type criteria:

is their any way i can restrict the hardware entries(when running a software query)(and vice versa) eventhough it doe fit the specified date range criteria....

I am totally all thunk out....can any help me...i'd be very gratefuls-)
 
Take a another look at your query. You have written:

...AND (([Forms]![hardsoftpopup]![cboType])<>False))


Shouldn't this be:
AND ((txtType = [Forms]![hardsoftpopup]![cboType]));

or something along those lines? Maq B-)
<insert witty signature here>
 
Thanks Maquis...i fixed that error but still mot working....any suggestions
 
If tblChange.Description is not the type then add tblChange.Type to your Select clause. Then in your last line shouldn't it be more like AND (tblChange.Type or Description=(([Forms]![hardsoftpopup]![cboType])<>False));
Also, you may want to start using aliases, for example, From tblChange AS Chg. Then everywhere you use tblChange you would use Chg instead, like Chg.Type. Also, I think it is alot easier to work with date if you use the Date/Time format, Short is usually best. That way you can start using Now() and Date(), which you will start to find very helpful in the future. Hope this helps you out, good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top