openargs multiple (1 Viewer)

Misiek

Registered User.
Local time
Today, 09:45
Joined
Sep 10, 2014
Messages
249
Hello all,

I followed this:
http://www.fmsinc.com/microsoftaccess/Forms/openargs/index.htm

which works perfectly, but When I want to add 3rd value or in the future potentially 4th, I'm struggling with code.
Can anyone advice please.


This is button command in form:
Code:
 Private Sub Command268_Click()
Dim entry1 As String
Dim entry2 As String
Dim entry3 As String
 entry1 = "QA Trigger " & Date
entry2 = InputBox("Enter 1st Comment")
entry3 = InputBox("Enter 2nd Comment")
 DoCmd.OpenReport "R_DailyTEST", View:=acViewPreview, OpenArgs:=entry1 & "|" & entry2 & "|" & entry3
End Sub

This in my report:
Code:
 Private Sub Report_Load()
  Dim intPos As Integer
  Dim entry1 As String
  Dim entry2 As String
  Dim entry3 As String
  
  If Len(Me.OpenArgs) > 0 Then
    ' Position of the pipe
    intPos = InStr(Me.OpenArgs, "|")
    If intPos > 0 Then
      entry1 = Left$(Me.OpenArgs, intPos - 1)
      entry2 = Mid$(Me.OpenArgs, intPos + 1)
      entry3 = Right$(Me.OpenArgs, intPos - 1)
      ' Assign the value to the control
      Me.txtTitle = entry1
      Me.txt1 = entry2
      Me.txt2 = entry3
    End If
  End If
End Sub

The first value works ok.
The second combines 2nd and 3rd entries
The third one shows half on second entry and entire 3rd entry

Thank you
 

Misiek

Registered User.
Local time
Today, 09:45
Joined
Sep 10, 2014
Messages
249
SUPERB!!!!!
Thank you :)
 

JHB

Have been here a while
Local time
Today, 11:45
Joined
Jun 17, 2012
Messages
7,732
You're welcome, good luck.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 10:45
Joined
Sep 12, 2006
Messages
15,695
if you aren't always passing the same number of arguments you could make the first argument the count of args.

so 2|"A"|"B"
or 3|"A"|"B"|12

you can split and then use ubound to determine how many arguments you passed, but if you explicitly say there are 3 arguments, and you don't actually have 3, you can detect the error more easily.
 

Users who are viewing this thread

Top Bottom