DLookup based on Query

G

Guest

Please help....Tired of trying diffferent ways nothing working.
Using sample of NW.DB Orders. It looks up the rate in Products

In my Service table (Which would be Products table), I have added taxes.
GST and PST.

based on the following

Private Sub ServiceID_AfterUpdate()
On Error GoTo Err_ServiceID_AfterUpdate

Dim strFilter As String

' Evaluate filter before it's passed to DLookup function.
strFilter = "ServiceID = " & Me!ServiceID

' Look up Service's unit price and assign it to UnitPrice control.
Me!UnitPrice = DLookup("UnitPrice", "Services", strFilter)



Exit_ServiceID_AfterUpdate:
Exit Sub

Err_ServiceID_AfterUpdate:
MsgBox Err.Description
Resume Exit_ServiceID_AfterUpdate

End Sub

Can I modify this to also on (After Update) hav thei look up the GST and PST
rate.

I have tried multiple things nothing works.......

Any help Please.......................Thank you.
 
G

Guest

' Evaluate filter before it's passed to DLookup function.
strFilter = "[ServiceID] = " & Me!ServiceID

If ServiceID is a text field, you need this syntax:
strFilter = "[ServiceID] = '" & Me!ServiceID & "'"

' Look up Service's unit price and assign it to UnitPrice control.
Me!UnitPrice = DLookup("[UnitPrice]", "Services", strFilter)
 
G

Guest

Hi Klatuu, thanks for response, but notice that line is already in the
result I posted.....Any other suggestions,
Appreciated.

Klatuu said:
' Evaluate filter before it's passed to DLookup function.
strFilter = "[ServiceID] = " & Me!ServiceID

If ServiceID is a text field, you need this syntax:
strFilter = "[ServiceID] = '" & Me!ServiceID & "'"

' Look up Service's unit price and assign it to UnitPrice control.
Me!UnitPrice = DLookup("[UnitPrice]", "Services", strFilter)


Lin said:
Please help....Tired of trying diffferent ways nothing working.
Using sample of NW.DB Orders. It looks up the rate in Products

In my Service table (Which would be Products table), I have added taxes.
GST and PST.

based on the following

Private Sub ServiceID_AfterUpdate()
On Error GoTo Err_ServiceID_AfterUpdate

Dim strFilter As String

' Evaluate filter before it's passed to DLookup function.
strFilter = "ServiceID = " & Me!ServiceID

' Look up Service's unit price and assign it to UnitPrice control.
Me!UnitPrice = DLookup("UnitPrice", "Services", strFilter)



Exit_ServiceID_AfterUpdate:
Exit Sub

Err_ServiceID_AfterUpdate:
MsgBox Err.Description
Resume Exit_ServiceID_AfterUpdate

End Sub

Can I modify this to also on (After Update) hav thei look up the GST and PST
rate.

I have tried multiple things nothing works.......

Any help Please.......................Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top