I am running into a weird problem in my MS Access report Database. I created it the other day. It has a general main screen that has a drop down report with 2 limits on it. Well, if you choose the report and go to the first limit and view, nothing comes up every time when you start the DB. But, when you restart the db, and select the report and try the 2nd limit, it works. Then when you try the 1st limit it works.
In order for the 1st limit to work you must open the db. and either run BOTH limits, or run the second limit, let the report open, then close it, then run the first one. I'm not sure whats going on.
The account type is the one giving me problems. I hope I could explain it well enough.
Here is my code, maybe it will be enough.
Expand|Select|Wrap|Line Numbers
- Public Function GetWhereCond() As String
- Dim whereCond As String
- With Forms!frmMain
- 'These are for Future Reference if I can find where these are stored
- If Nz(!ServiceNumber.Value, "") <> "" Then whereCond = whereCond & " AND (ServiceNumber = " & """" & !ServiceNumber.Value & """" & ")"
- If Nz(!MTWAccount.Value, "") <> "" Then whereCond = whereCond & " AND (ServiceNumber = " & """" & !MTWAccount.Value & """" & ")"
- If Nz(!InvoiceGroup.Value, "") <> "" Then whereCond = whereCond & " AND (ServiceNumber = " & """" & !InvoiceGroup.Value & """" & ")"
- If Nz(!RetailAccount.Value, "") <> "" Then whereCond = whereCond & " AND (ServiceNumber = " & """" & !RetailAccount.Value & """" & ")"
- 'I haven't decided where to pull the Date Field from so I put in a General Name
- 'If Nz(!HighDate, "") <> "" Then whereCond = whereCond & " AND (CUSTOMER.DATE >= #" & !HighDate.Value & "#)"
- 'If Nz(!LowDate, "") <> "" Then whereCond = whereCond & " AND (CUSTOMER.DATE <= #" & !LowDate.Value & "#)"
- 'If Nz(!cmbRegion, "") <> "" Then whereCond = whereCond & " AND (CUSTOMER.CustomerState = '" & !cmbRegion.Value & "')"
- If Nz(!cmbAccountType, "") <> "" Then whereCond = whereCond & " AND (CUSTOMER.AccountType = " & !cmbAccountType.Value & ")"
- If Nz(!cmbAccountStatus, "") <> "" Then whereCond = whereCond & " AND (CUSTOMER.AccountStatus = " & !cmbAccountStatus.Value & ")"
- End With
- If whereCond = "" Then
- GetWhereCond = ""
- Else
- GetWhereCond = "(" & Right(whereCond, Len(whereCond) - 5) & ")"
- End If
- End Function