Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dlookup form one table to another

Status
Not open for further replies.

fludan

Technical User
Feb 1, 2002
41
0
0
US
Hi
I am traging to get info from my table product, if the product taxe is set to no(yes/no chek box)I want the product in my subform to stai to no and if the product is set to yes I want to go to the Eles statement in my example I trayed to do :-(

If Me![orderdetails.gstID] = (DLookup("[gstID]", "[product]", "[productID]=Forms![orders]![ordersdetails subform].Form![ID]")) = -1 Then
Me![orderdetails.gstID] = -1
Else
Me![orderdetails.gstID] = (Forms![Orders].Form![customer.gstID]) - (DLookup("[gstID]", "[product]", "[productID]=Forms![orders]![ordersdetails subform].Form![ID]")) + (DLookup("[gstID]", "[product]", "[productID]=Forms![orders]![ordersdetails subform].Form![ID]"))
End If
 
Okay,

You have some problems with the first branch of your IF statement. You are trying to compare Me![orderdetails.gstID] twice in the same statement with out an 'Or', 'And'. What do you want your If statement to compare?

1. Are you trying to compare Me![orderdetails.gstID] to your Dlookup? Try this:
Dim TempGSTVal

TempGSTVal = DLookup("[gstID]", "[product]", "[productID]=Forms![orders]![ordersdetails subform].Form![ID]")

If Me![orderdetails.gstID] = TempGSTVal Then
*YOUR CODE*
Else
*YOUR CODE*
End If

2. Are you trying to compare the dlookup value and see if it returns a -1? If so try this:

Dim TempGSTVal

TempGSTVal = DLookup("[gstID]", "[product]", "[productID]=Forms![orders]![ordersdetails subform].Form![ID]")

If TempGSTVal = -1 Then
*YOUR CODE*
Else
*YOUR CODE*
End If

jbehrne
If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
 
Thanks for your help but I just figured it out an hour ago

That's what I did:
If Me![product.pstID] = False Then
Me![orderdetails.pstID] = False
Else
Me![orderdetails.pstID] = (Forms![Orders].Form![customer.pstID]) - (DLookup("[pstID]", "[product]", "[productID]=Forms![orders]![ordersdetails subform].Form![ID]")) + (DLookup("[pstID]", "[product]", "[productID]=Forms![orders]![ordersdetails subform].Form![ID]"))
End If
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top