473,385 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Is there a way to determine how many variables does OpenArgs contain?

Hi, that is basically my question there in the title
If someone knows..
May 5 '10 #1

✓ answered by missinglinq

Assuming you're doing this way it's usually done, with a delimiting character between each item you're passing, you could do this:
Expand|Select|Wrap|Line Numbers
  1. Dim vars As Integer
  2.  
  3. If Not IsNull(Me.OpenArgs) Then
  4.  
  5. If InStr(Me.OpenArgs, ";") = 0 Then
  6.    vars = 1
  7. Else
  8.   vars = Len(Me.OpenArgs) - Len(Replace(Me.OpenArgs, ";", "")) + 1
  9. End If
  10.  
  11. End If


This assumes you're using a semi-colon as the delimiting character. You can modify for another character, if need be.

Welcome to Bytes!

Linq ;0)>

14 2934
Megalog
378 Expert 256MB
The OpenArgs property of a form/report is just a string which value is set by (usually) using a DoCmd.OpenForm/OpenReport command. It can contain multiple variables in the string, if that's what you place there. Parsing those variables out can be done with custom functions, or maybe even the Split() command.

You'll need to be a lot more detailed with your questions if you want any further help.
May 5 '10 #2
Thanks for replying, Megalog
Sorry if i wasn't clear, but i wasn't asking how the OpenArgs works, i know how to use it. My question was, presuming i already used it and passed several variables, once i 'catch' this OpenArgs string - is there a way to know how many variables were passed in it originally (=how many variables does openargs contain).
It's not that important, i just wanted to know if it can be done...
May 5 '10 #3
Megalog
378 Expert 256MB
OpenArgs is a temporary variable, that as far as I know, is only stored in memory while that form is open. There is no history to it, etc. You're able to play with whatever data is currently in there at that moment, that's it. So, there is only 1 variable at any time.
May 5 '10 #4
gershwyn
122 100+
@TravelingCat
Like Megalog stated, the OpenArgs parameter is a single string variable that is passed to the form or report. If you are passing multiple values through it, then you must be combining those values into a string. The method you use to determine how many values it contains depends entirely on the method you used to combine them in the first place.

If you want to post the code you used to pass the values, I'm sure someone can show you a way to count the values OpenArgs contains. Without seeing the calling code though, there isn't anything more to be said.
May 5 '10 #5
missinglinq
3,532 Expert 2GB
Assuming you're doing this way it's usually done, with a delimiting character between each item you're passing, you could do this:
Expand|Select|Wrap|Line Numbers
  1. Dim vars As Integer
  2.  
  3. If Not IsNull(Me.OpenArgs) Then
  4.  
  5. If InStr(Me.OpenArgs, ";") = 0 Then
  6.    vars = 1
  7. Else
  8.   vars = Len(Me.OpenArgs) - Len(Replace(Me.OpenArgs, ";", "")) + 1
  9. End If
  10.  
  11. End If


This assumes you're using a semi-colon as the delimiting character. You can modify for another character, if need be.

Welcome to Bytes!

Linq ;0)>
May 5 '10 #6
missinglinq, thanks a lot, that is exactly what i needed:) Indeed i used ";" as a delimiter, so the code does what i asked for.
Thanks for other replies also
May 6 '10 #7
You can simply use the Split command for the OpenArgs value which will assign the results to an array (0 based). You can then use the UBound command to figure out the number of variables.

Expand|Select|Wrap|Line Numbers
  1. Dim astrValues() As String
  2. If Not IsNull(Me.OpenArgs) Then
  3.   astrValues = Split(Me.OpenArgs, ";")
  4.   intVars = UBound(astrValues) + 1
  5. End If
May 9 '10 #8
ADezii
8,834 Expert 8TB
The following Function, in a Form Module will return either the Number of Arguments passed, NULL, or a Descriptive Error Message.
Expand|Select|Wrap|Line Numbers
  1. Private Function fNumberOfArgs() As Variant
  2. On Error GoTo Err_fNumberOfArgs
  3.  
  4. fNumberOfArgs = UBound(Split(Me.OpenArgs, ";")) + 1
  5.  
  6. Exit_fNumberOfArgs:
  7.   Exit Function
  8.  
  9. Err_fNumberOfArgs:
  10.   If Err.Number = 94 Then       'No OpenArgs
  11.     fNumberOfArgs = Null
  12.   Else
  13.     MsgBox Err.Description, vbExclamation, "Error in fNumberOfArgs()"
  14.       Resume Exit_fNumberOfArgs
  15.   End If
  16.     Resume Exit_fNumberOfArgs
  17. End Function
May 9 '10 #9
NeoPa
32,556 Expert Mod 16PB
TravelingCat: Hi, that is basically my question there in the title
If someone knows..
It is clearly important in this case to explain that you are passing multiple items across as a delimited string. I'm sure it saved you some time not including that info, but it's equally clear that it took up the time of various others trying to help you, to work out what you should have made clear in your question in the first place. Please try to be more specific with your questions in future.

Administrator.
May 10 '10 #10
NeoPa, i assure you that i did not NOT mention it because i was trying to save time, but of sheer belief that the question was clear. But i explained myself immediately after the first reply, so again, sorry for vagueness.
May 12 '10 #11
NeoPa
32,556 Expert Mod 16PB
If you're happy you did the best you could in the circumstances then I'm happy.

In truth, clear communication is difficult at the best of times, which is why I try to encourage care wherever possible.
May 12 '10 #12
And i agree with you. But in this case, it seems like you are a little bit too hursh on me.
I suggest we leave it at that.
May 13 '10 #13
NeoPa
32,556 Expert Mod 16PB
You are funny :)
May 13 '10 #14
Funny is a great quality, i'll take it
May 13 '10 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: G-Factor | last post by:
Hi all Been learning C++ for about 5 weeks. I find that I create quite a lot of variables. Generally, is it better to create a new variable for every different thing that needs to be stored in...
4
by: Arjen | last post by:
What does this mean? 'Roles' does not contain a definition for 'RoleExists' I'm doing this: using System.Web.Security; Roles.DeleteRole(txtRolename.Text.Trim()); I don't see what's wrong. ...
3
by: ohayo | last post by:
In a windows form app (which acts as a front end to my quickfix application), I get the following error on compiling Application does not contain a definition for 'Run'. What does this mean,...
1
by: ssims | last post by:
I've got this code for a random GDI+ chart generator, and the demo works, but when I try to run it on my local machine I get a compiler error: Compiler Error Message: CS0117: 'Random' does not...
1
by: jobs | last post by:
CommandArgument does not contain row index when command under Templatefield of- Gridview It appears CommandArgument passed to the rowcommand event does not contain row index when the command is...
2
by: J Miro | last post by:
When I call the Generic method ShowName in the following code, I get the error message "'T' does not contain a definition for 'Name'." Does anyone know why? Thanks in advance. Jay. ...
3
by: =?Utf-8?B?V2FsaWQ=?= | last post by:
Hello: I have migrated a site from IIS5 to IIS6. The site is configured and the we app is installed on the new IIS site. I can get to the web page but when I try to login, this is what I get...
2
by: cephal0n | last post by:
Hi All! I have a field named: Title,now I want to filter the data with a specific match. In Excel when you set the whole sheet1 to data>filter>autofilter, excel offers an Custom AutoFilter...
1
by: HarishAdea | last post by:
Hi, I am trying to run the JAVA pgm, but it is giving error as "selection does not contain a main type". The filename is "ScoreLeadSummary.java" when i try to run it or debug,it gives the pop...
2
boss32178
by: boss32178 | last post by:
Ok I get this error when i try to run the web app. foreach statement cannot operte on variables of type 'object' does not contain a public definition for 'GetEnumerator' here is the code #region...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.