Full Version: Openargs Problem
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
spooker
Hi,

I have a form that looks up quotes to customers. At the time of creating the quote, the parts may not be set up on the system. If the customers later accept the quote, I want to be able to open a form with the quote details and then have an option to create the part on the system without having to keep closing one form and opening another.

I have set the contol on the quotes form that opens a second form to add the new part (ProductAdd), but I'm having problems passing the OpenArgs values.

The three values I want to pass to the ProductsAdd form are:

ProductId - The part number
ProductName -The part description
CustomerId - The customer identifier which is on a parent form.

I've set up a function ParsText:

CODE
Public Function ParseText(TextIn As String, x) As Variant
On Error Resume Next
Dim Var As Variant
Var = Split(TextIn, "|", -1)
ParseText = Var(x)

End Function


Then when I click on the control it runs the following code:

CODE
Private Sub SetUpPart_Click()
On Error GoTo Err_SetUpPart_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ProductsAdd"
DoCmd.OpenForm stDocName, , , , , , "'ProductId'|'ProductName'|'Me!Parent.QCustomerId'"

Exit_SetUpPart_Click:
Exit Sub
End Sub


Then on the ProductsAdd form I have the OnLoad event:

CODE
Private Sub Form_Load()

If Not IsNull(Me.OpenArgs) Then
Dim strA As String
Dim strB As String
Dim strC As String

strA = ParseText(OpenArgs, 0)
strB = ParseText(OpenArgs, 1)
strC = ParseText(OpenArgs, 2)

ProductId = strA
ProductName = strB
CustomerId = strC
End If

End Sub


My problem is that I can't get the argumnets to pass their actual values. For example, if ProductId on the quote is 123456, it actually comes out as 'ProductId' and the description comes out as 'ProductName'.

I've tried using the square brackets around the values "[ProductId]|[ProductName]|[Me!Parent.QCustomerId]", but this still doesn't work.

Any help appreciated

Terry

strBean
Assuming these are variables, you can concatenate them into a string for OpenArgs thusly:

ProductId & "|" & ProductName & "|" & Me!Parent.QCustomerId
spooker
Thanks Sam, worked a treat! thumbup.gif

One day I'll get all this syntax sorted - until then I'm glad there's this forum.
strBean
yw.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.