yargh...it still doesn't work...seems like the code is cursed... =P i'll post the code...hope it isn't TOO confusing. btb, i notice you're from newcastle. this is a long shot, but would you happen to know an Andrew Done there? he goes to uni there.
For the code: concentrate on how it gets to "stDocName = rptProdMktMkrInd" and then prints it at the very end. if this is too long, just tell me. =P it's divided into sections depending on what the user enters or does not enter on a form.
Set db = CurrentDb()
stDocName = "rptProdMktMkr"
stDocName2 = "rptProdMktMkrToday"
Set rec = db.OpenRecordset("Trade Table")
d = 1
If cboMktMkrInd > " " And txtSecurity <= " " Then
d = 0
e = 0
Do While Not rec.EOF
If rec("trade_date") >= txtBeginDate And rec("trade_date") <= txtEndDate Then
If rec("Market_Maker_ID") = cboMktMkrInd Then d = 1
End If
If chkToday = True And rec("trade_date") = txtEndDate And rec("Market_Maker_ID") = cboMktMkrInd Then e = 1
rec.MoveNext
Loop
rec.Close
stDocName = "rptProdMktMkrInd"
stDocName2 = "rptProdMktMkrIndToday"
If chkSyndicate = True Then
stDocName = "rptProdMktMkrIndNoSynd"
stDocName2 = "rptProdMktMkrIndTodayNoSynd"
End If
End If
Set rec = db.OpenRecordset("Trade Table")
If txtSecurity > " " And cboMktMkrInd <= " " Then
d = 0
e = 0
Do While Not rec.EOF
If rec("trade_date") >= txtBeginDate And rec("trade_date") <= txtEndDate Then
If rec("Security_Symbol") = txtSecurity And rec("Market_Maker_ID") > "" Then d = 1
End If
If chkToday = True And rec("Trade_date") = txtEndDate And rec("Security_Symbol") = txtSecurity And rec("Market_Maker_ID") > "" Then e = 1
rec.MoveNext
Loop
rec.Close
stDocName = "rptProdMktMkrAllSecInd"
stDocName2 = "rptProdMktMkrAllSecIndToday"
If chkSyndicate = True Then
stDocName = "rptProdMktMkrAllSecIndNoSynd"
stDocName2 = "rptProdMktMkrAllSecIndTodayNoSynd"
End If
End If
Set rec = db.OpenRecordset("Trade Table")
If txtSecurity > "" And cboMktMkrInd > " " Then
d = 0
Do While Not rec.EOF
If rec("trade_date") >= txtBeginDate And rec("trade_date") <= txtEndDate Then
If rec("Security_Symbol") = txtSecurity And rec("Market_Maker_ID") = cboMktMkrInd Then d = 1
End If
If chkToday = True And rec("Trade_Date") = txtEndDate And rec("Security_Symbol") = txtSecurity And rec("Market_Maker_ID") = cboMktMkrInd Then e = 1
rec.MoveNext
Loop
rec.Close
stDocName = "rptProdMktMkrIndSecInd"
stDocName2 = "rptProdMktMkrIndSecIndToday"
If chkSyndicate = True Then
stDocName = "rptProdMktMkrIndSecIndNoSynd"
stDocName2 = "rptProdMktMkrIndSecIndTodayNoSynd"
End If
End If
Set rec = db.OpenRecordset("Trade Table")
If stDocName = "rptProdMktMkr" Then
d = 2
e = 1
Do While Not rec.EOF
If rec("trade_date") >= txtBeginDate And rec("trade_date") <= txtEndDate Then
If rec("Market_Maker_ID") > " " Then d = 1
End If
rec.MoveNext
Loop
rec.Close
If chkSyndicate = True Then
stDocName = "rptProdMktMkrNoSynd"
stDocName2 = "rptProdMktMkrTodayNoSynd"
End If
End If
If d = 0 Then response = MsgBox("Records for '" & cboMktMkrInd & "' do not exist for the security, " & txtSecurity & ", within the time range of " & txtBeginDate & " - " & txtEndDate & ".", , "End of Query")
If chkToday = True And e = 0 Then response = MsgBox("Records for '" & cboMktMkrInd & "' do not exist for the security, " & txtSecurity & ", for the day: " & txtEndDate, , "Data Error")
If d = 1 Then
DoCmd.OpenReport stDocName, acViewPreview
If chkToday = True And e = 1 Then DoCmd.OpenReport stDocName2, acViewPreview
End If
If d = 2 Then response = MsgBox("No Market Maker records exist from " & txtBeginDate & " - " & txtEndDate & ".", , "End of Query")
txtSecurity = ""
cboMktMkrInd = ""