Conditional Statesments in Access.

K

Kalor

This a multiple part question. Below is what I would like to try and do.

I have a field called Order Qty which is the Qty Received of a product on a
purchase order. I would like the on exit event for this field to bring up a
form to enter Serial Numbers if the Category ID in the Products table
contains a 1 or a 2 otherwise not do anything. How would this be accomplished?
 
S

Sharkbyte

If I am understanding this correctly, try something like this:

Dim CatID as Integer
CatID = DLookup("CategoryID", "tblProducts", "ProductID = [forms]![<current
form>]![ProductID]")

If CatID = 1 or CatID = 2 Then
DoCmd.OpenForm "<form name>"
Else
End If

HTH

Sharkbyte
 
K

Kalor

I put the code in and it tells me I cancelled the previous Operation. Here Is
what I have in there

Dim CatID As Integer
CatID = DLookup("CategoryID", "Product", "[ProductID] = [forms]![<current
form>]![ProductID]")

If CatID = 1 Or CatID = 2 Then
DoCmd.OpenForm ("Serial Number")
Else
End If


Am I doing something Wrong?
--
May your right hand be forever extended in friendship, but never in want.


Sharkbyte said:
If I am understanding this correctly, try something like this:

Dim CatID as Integer
CatID = DLookup("CategoryID", "tblProducts", "ProductID = [forms]![<current
form>]![ProductID]")

If CatID = 1 or CatID = 2 Then
DoCmd.OpenForm "<form name>"
Else
End If

HTH

Sharkbyte



Kalor said:
This a multiple part question. Below is what I would like to try and do.

I have a field called Order Qty which is the Qty Received of a product on a
purchase order. I would like the on exit event for this field to bring up a
form to enter Serial Numbers if the Category ID in the Products table
contains a 1 or a 2 otherwise not do anything. How would this be accomplished?
 
S

schasteen

Slight error in dlookup statement
CatID = DLookup("CategoryID", "Product", "[ProductID] = " & Me![ProductID])

Also, you need to put the correct names in for your tables, forms, and
controls.


Kalor said:
I put the code in and it tells me I cancelled the previous Operation. Here Is
what I have in there

Dim CatID As Integer
CatID = DLookup("CategoryID", "Product", "[ProductID] = [forms]![<current
form>]![ProductID]")

If CatID = 1 Or CatID = 2 Then
DoCmd.OpenForm ("Serial Number")
Else
End If


Am I doing something Wrong?
--
May your right hand be forever extended in friendship, but never in want.


Sharkbyte said:
If I am understanding this correctly, try something like this:

Dim CatID as Integer
CatID = DLookup("CategoryID", "tblProducts", "ProductID = [forms]![<current
form>]![ProductID]")

If CatID = 1 or CatID = 2 Then
DoCmd.OpenForm "<form name>"
Else
End If

HTH

Sharkbyte



Kalor said:
This a multiple part question. Below is what I would like to try and do.

I have a field called Order Qty which is the Qty Received of a product on a
purchase order. I would like the on exit event for this field to bring up a
form to enter Serial Numbers if the Category ID in the Products table
contains a 1 or a 2 otherwise not do anything. How would this be accomplished?
 
K

Kalor

That hass done it. Thanks for your help everyone.
--
May your right hand be forever extended in friendship, but never in want.


schasteen said:
Slight error in dlookup statement
CatID = DLookup("CategoryID", "Product", "[ProductID] = " & Me![ProductID])

Also, you need to put the correct names in for your tables, forms, and
controls.


Kalor said:
I put the code in and it tells me I cancelled the previous Operation. Here Is
what I have in there

Dim CatID As Integer
CatID = DLookup("CategoryID", "Product", "[ProductID] = [forms]![<current
form>]![ProductID]")

If CatID = 1 Or CatID = 2 Then
DoCmd.OpenForm ("Serial Number")
Else
End If


Am I doing something Wrong?
--
May your right hand be forever extended in friendship, but never in want.


Sharkbyte said:
If I am understanding this correctly, try something like this:

Dim CatID as Integer
CatID = DLookup("CategoryID", "tblProducts", "ProductID = [forms]![<current
form>]![ProductID]")

If CatID = 1 or CatID = 2 Then
DoCmd.OpenForm "<form name>"
Else
End If

HTH

Sharkbyte



:

This a multiple part question. Below is what I would like to try and do.

I have a field called Order Qty which is the Qty Received of a product on a
purchase order. I would like the on exit event for this field to bring up a
form to enter Serial Numbers if the Category ID in the Products table
contains a 1 or a 2 otherwise not do anything. How would this be accomplished?
 

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