Leading "=" Lost in OpenArgs String

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Greetings

I'm using Access 2002 SP3. I have a form in which clicking on a button is supposed to open a second form and pass a string to it. So in the "On click" event procedure for the button, I coded this

Dim stDocName as String, s as Strin
..
stDocName = "OrgForm
DoCmd.OpenForm stDocName, , , , , ,

If the value of "s" happens to begin with an "=" character, the "=" gets stripped off somehow by the time the form's Open event procedure is called. For example if s has the value "=12345" (as verified by Debug) when OpenForm is invoked, then at the start of the second form's Open event procedure I will see (again with Debug) that Me.OpenArgs has the value "12345". Other leading characters are passed correctly, e.g. if s contains "*12345", the entire string is passed correctly from the first form to the second

Can anyone explain this, or does it only happen to me

All help appreciated

- Scott.
 
Hi Scott. I can verify your bug, and it exists in A2000 and A2003 also.

It looks like Access tries to evaluate the OpenArgs string if it begins with
an equal sign:

OpenArgs Result

"=123" 123
"=""dog""" dog
"=dog" Error 2498 (wrong data type)

CStr() does not work around the problem.

Leading and trailing spaces are also stripped from the string if the first
non-space character is an equal sign.

The flaw is not present in Access 97.

You might consider reporting this bug to Microsoft.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Scott Inrig said:
I'm using Access 2002 SP3. I have a form in which clicking on a button is
supposed to open a second form and pass a string to it. So in the "On
click" event procedure for the button, I coded this:
Dim stDocName as String, s as String
...
stDocName = "OrgForm"
DoCmd.OpenForm stDocName, , , , , , s

If the value of "s" happens to begin with an "=" character, the "=" gets
stripped off somehow by the time the form's Open event procedure is called.
For example if s has the value "=12345" (as verified by Debug) when
OpenForm is invoked, then at the start of the second form's Open event
procedure I will see (again with Debug) that Me.OpenArgs has the value
"12345". Other leading characters are passed correctly, e.g. if s contains
"*12345", the entire string is passed correctly from the first form to the
second.
 
Back
Top