Form Open Multiple Arguments (1 Viewer)

hascons

Registered User.
Local time
Today, 15:46
Joined
Apr 20, 2009
Messages
58
Hello ,

I'm trying to open a form from a main form that gets information from the main form.

I usually do this when only one argument needs to be passed, however I need to pass multiple arguments and the are all Numbers(Integers). I found some examples where you string them together with a separator (|). I know this passes the arguments but I Keep getting an error message that I'm using the wrong type.

Does any one have any Idea as to what I can do to make this work?

This Code is on my main Form.
Private Sub cmdAddCostItem_Click()
Dim stDocName As String
Dim stLink As String
Dim a As Integer
Dim b As Integer
Dim c As Integer

a = Me.txtDivisionID
b = Me.txtSubDivisionID
c = 1

stLink = "a|b|c"

stDocName = "frmCostItemDetails"
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, acNormal, stLink

End Sub


This Code is On My 2nd Form.

Private Sub Form_Load()
Dim strA As String
Dim strB As String
Dim strC As String

If Not IsNull(Me.OpenArgs) Then
strA = ParseText(OpenArgs, 0)
strB = ParseText(OpenArgs, 1)
strC = ParseText(OpenArgs, 2)

Me.DivisionID = strA
Me.SubDivisionID = strB
Me.BidCategoryID = strC

End If

End Sub


This code is from a Public Module.

Public Function ParseText(TextIn As String, x) As Variant

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

boblarson

Smeghead
Local time
Today, 15:46
Joined
Jan 12, 2001
Messages
32,059
You are sending the literal a|b|c instead of their values:

Code:
Dim stDocName As String
Dim stLink As String
Dim a As Integer
Dim b As Integer
Dim c As Integer
 
a = Me.txtDivisionID
b = Me.txtSubDivisionID
c = 1
[B][COLOR=seagreen]' change this:[/COLOR][/B]
[B][COLOR=seagreen]'stLink = "a|b|c"[/COLOR][/B]
[B][COLOR=seagreen]'to this[/COLOR][/B]
[B][COLOR=red]stLink = a & "|" & b & "|" & c[/COLOR][/B]
 
stDocName = "frmCostItemDetails"
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd, acNormal, stLink
 

John Big Booty

AWF VIP
Local time
Tomorrow, 08:46
Joined
Aug 29, 2005
Messages
8,263
I suspect that you problem is in this line of code;
Code:
stLink = a|b|c
As you have enclosed a|b|c in double quotes you are assigning stLink the string value of a|b|c, so when you function breaks that do it is trying to the letters a, b, and c to your various ID's.

Try;
Code:
stLink =  a & "|" & b & "|" & c
 

boblarson

Smeghead
Local time
Today, 15:46
Joined
Jan 12, 2001
Messages
32,059
Doh! too slow :eek:
We each get that at times.

 

Users who are viewing this thread

Top Bottom