In your Case Else, you open the recordset, but you never assign it to the
form's Recordset property. Also, your error handler isn't going to tell you
anything if an error occurs. The code will just fail silently with no
indication of what the problem might be. What happens if you run this code
with the error handling option set to "Break on all errors"? What's the data
type of the CustBool parameter?
still no go,
Option Explicit
Dim Custrst As DAO.Recordset
Dim CMdb As DAO.Database
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_OpenF
Dim rs As DAO.Recordset
If Not IsNull(Me.OpenArgs) Then
Select Case Me.OpenArgs
Case "Cust"
Set CMdb = CurrentDb
CMdb.QueryDefs("qrycustdet").Parameters("[CustBool]").Value = 1
Me.Caption = "Customer details"
Case "Sup"
CMdb.QueryDefs("qrycustdet").Parameters("[CustBool]").Value = 0
Me.Caption = "Supplier details"
Case Else
CMdb.QueryDefs("qrycustdet").Parameters("[CustBool]").Value = ""
Set Custrst = CMdb.QueryDefs("qryCustDet").OpenRecordset
GoTo Exit_OpenF
End Select
End If
Set Custrst = CMdb.QueryDefs("qryCustDet").OpenRecordset
Set Me.Recordset = Custrst
DoCmd.Restore
Exit_OpenF:
Exit Sub
Err_OpenF:
Cancel = True
Resume Exit_OpenF
End Sub
is there anything else wrong with my code?
thnx
[/QUOTE][/QUOTE]
I did manage to make it work on your advices
there was indeed a problem with the parameter's data type
I tried to cast it from string to YES/NO
then I get this error number 3421 every time
the "set CMdb" was just a mistyping of me
so now it does work when I pass 1 or 0 for the first 2 cases but no
show for the Case Else
can I pass a null value instead of 0 or 1 for a YES/NO field?
I made the parameter display all records if no parameter value is
entered
but when I pass "" or vbnull it gives me the same error from above
when I call the query manually and enter nothing it does give me all
records
thnx a bunch for your help so far