Another DLookup problem with 3 criteria

JiTS

Ciao!
Local time
Today, 13:56
Joined
Dec 12, 2003
Messages
77
Hi,

I searched the forum for this problem but my problem is still unique. :(

Problemsituation (see attachment):
I have a form (frmAanvoergegevens) with 3 fields:

* Contractnummer - txtContractnummer - textbox - numerical
* Productcode - cboProductcode - combo box - text
* Leverancierscode - cboLeverancierscode - combo box - text

I also use a table called tblContracten. The fields above are also in that table.

Question:
If I click on the button 'Opslaan' I want to check if the fields (which are filled in) are the same as the fields in the table tblContracten. If yes, then a message will pop-up.

Until so far I used the following code:

Code:
If Not IsNull(DLookup("[txtContractnummer]", _
    "tblContracten", "[Contractnummer] = " & Me.txtContractnummer _
    & " And [Productcode] = '" & Me.cboProductcode _
    & "'" And "[Leverancierscode] = '" & Me.cboLeverancierscode & "'")) Then
        
    MsgBox "The contract is ok.", vbExclamation
    End If
I need some help...


Regards,
JiTS
 

Attachments

  • problemsituation.jpg
    problemsituation.jpg
    10.8 KB · Views: 141
Try This:
If DCount("[txtContractnummer]", _
"tblContracten", "[Contractnummer] = " & Me.txtContractnummer _
& " And [Productcode] = '" & Me.cboProductcode _
& '" And [Leverancierscode] = '" & Me.cboLeverancierscode & "'") = 0 Then

MsgBox "The contract is ok.", vbExclamation
End If

This assumes ContractNummer is numeric
 
FoFa,

Thanks for your reply.

Contractnummer is numeric, that's true.

You're code is not correct, because I get an error on the line:

Code:
& '" And [Leverancierscode] = '" & Me.cboLeverancierscode & "'") = 0 Then

I guess there is missing a quote (") but where I don't know. :confused:
 
Oops, the single and double quotres are switched around.
Change it to
& "' And [Leverancierscode] = '" & Me.cboLeverancierscode
 
FoFa,

Yes, that's it!

I was a little confused by all the characters in my written code. ;)

Thanks for your time.


*SMiLE*
JiTS
 
Last edited:

Users who are viewing this thread

Back
Top Bottom