If-Else Help

bmcgree1

Registered User.
Local time
Today, 13:22
Joined
Jun 19, 2009
Messages
43
I'm trying a print report command that first looks to see if a particular document has been printed. This is kept in one of the tables if a Yes/No field called "Print1". I'm trying to tell my If-Else Statement to look to here and if it is Yes (-1) then display a Yes/No Message Box.

Everytime I try and run it, it gives me an "Object Required" error message. I don't know what this means. My form is not bound because the Reports are run off queries that look to the drop-down control on my page which has a bound column 1 = LoanID. I want my If-Else to look to this control, take the LoanID that I have currently selected and look to see if Print1 = -1. Here's what I've been working with:

If tbl_LoanInfo.Print1 = -1 And MsgBox("This has already been printed.", vbYesNo, "Print Again?") = vbYes Then

Any help is greatly appreciated. Thank you.
 
If tbl_LoanInfo.Print1 = -1 And MsgBox("This has already been printed.", vbYesNo, "Print Again?") = vbYes Then

You can't get a value from a table like that. You will need either a DLookup or Recordset. I would go with the DLookup:

If DLookup("Print1","tbl_LoanInfo")=-1 And MsgBox("This has already been printed.", vbYesNo, "Print Again?") = vbYes Then
 
great thank you! I had to break up the if statement (into 2 if, if statements), becuase it seemed that no matter what (whether Print1 = 0 or -1) it still gave me the Yes/No question. It was like I put 'Or' instead of 'And' but whatever, it works. Thanks for the help!
 
great thank you! I had to break up the if statement (into 2 if, if statements), becuase it seemed that no matter what (whether Print1 = 0 or -1) it still gave me the Yes/No question. It was like I put 'Or' instead of 'And' but whatever, it works. Thanks for the help!

Oh, actually it would have been this then:

Code:
If DLookup("Print1","tbl_LoanInfo")=-1 Then
   If MsgBox("This has already been printed.", vbYesNo, "Print Again?") = vbYes Then 
      'Do your code stuff here
   End If
End If
 

Users who are viewing this thread

Back
Top Bottom