how to pass data from pop up form

J

Jon

I have main form that it has a subform. The continues subform is to show
customer orders and it has a button for each record to show the Products
Explore form in order to select the product ID and explore it. In the pop up
form†Products Explore†there is a button to add the products ID and Color ID
to the subform, but I cannot figure out the code to do this idea. Any help
please
 
T

Tom Wickerath

Hi Jon,

You just need to run the appropriate append query to append (add) the
product id and color id for the customer involved.

You can use the optional OpenArgs argument to pass the OrderID value to your
popup form. Alternatively, you can create an expression that grabs the
OrderID value from the named form. For example:

Code in Popup form:
OrderID = Forms!FormName!NameOfSubformControl!Form!NameOfControl

where FormName is the name of your customers form, NameOfSubformControl is
the name of the control that holds the Orders subform (which may be different
from the actual name of the form) and NameOfControl is the name of the
control that has the OrderID value.

The click event of a command button can be used to initiate the append
query. Something like this:

Option Compare Database
Option Explicit

Private Sub cmdAddProduct_Click()
On Error GoTo ProcError

Dim strSQL As String

strSQL = "INSERT INTO [OrderDetails] ([OrderID], [ProductID], [ColorID]) " _
& "VALUES (" & OrderID & ", " & ProductID & ", " & ColorID & ")"

Debug.Print strSQL '<---Use for debugging purposes only. Allows one to copy
' the resulting SQL statement to a new
query for testing.

CurrentDb.Execute strSQL, dbFailOnError

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure cmdAddProduct_Click..."
Resume ExitProc
End Sub


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________
 

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