473,395 Members | 1,413 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,395 software developers and data experts.

Building an expressions where parts are unknown at design time

I want the value of [ContactID] of the Calling form Form1.
How do I do this?

===============================
'Some Form (the calling form Form1)

Private Sub cmdOpenForm2_Click()
Dim strNameOfForm1 As String
strNameOfForm1 = Me.Name
DoCmd.OpenForm "Form2", , , , , , strNameOfForm1
End Sub
===============================

===============================
'Called Form (the called form Form2)

Private Sub Form2_Load()
If Not IsNull(Me.OpenArgs) Then

Dim strNameOfCallingForm As String
Dim ContactIDFromCallingForm

'Get the open arguments
'(The name of the form that called this form)
strNameOfCallingForm = Me.OpenArgs

'Find the value of the ContactID of the source form
'You can see below what I am trying to do
'But how do I do it????
'I need both the name of the calling form and an ID from that form
ContactIDFromCallingForm = Forms![Me.OpenArgs]![ContactID]

'Do other things
'Use strNameOfCallingForm for other things
'Use ContactIDFromCallingForm for other things
Else
'Do nothing
End If

End Sub
===============================

Yes, I can write a case statement with all the possibilities provided,
and all the possible expressions.
There are other convoluted ways too, but is that the most elegant way?
Nov 12 '05 #1
3 1240
"Douglas Buchanan" <db*********@comcast.net> wrote in message
news:db*************************@posting.google.co m...
I want the value of [ContactID] of the Calling form Form1.
How do I do this?

===============================
'Some Form (the calling form Form1)

Private Sub cmdOpenForm2_Click()
Dim strNameOfForm1 As String
strNameOfForm1 = Me.Name
DoCmd.OpenForm "Form2", , , , , , strNameOfForm1
End Sub
===============================

===============================
'Called Form (the called form Form2)

Private Sub Form2_Load()
If Not IsNull(Me.OpenArgs) Then

Dim strNameOfCallingForm As String
Dim ContactIDFromCallingForm

'Get the open arguments
'(The name of the form that called this form)
strNameOfCallingForm = Me.OpenArgs

'Find the value of the ContactID of the source form
'You can see below what I am trying to do
'But how do I do it????
'I need both the name of the calling form and an ID from that form
ContactIDFromCallingForm = Forms![Me.OpenArgs]![ContactID]

'Do other things
'Use strNameOfCallingForm for other things
'Use ContactIDFromCallingForm for other things
Else
'Do nothing
End If

End Sub
===============================

Yes, I can write a case statement with all the possibilities provided,
and all the possible expressions.
There are other convoluted ways too, but is that the most elegant way?



Have you considered combining more than one piece of information in the
OpenArgs string?

Dim strOpenArgs As String
strOpenArgs = Me.Name & "|" & Nz(Me!ContactID,0)
DoCmd.OpenForm "Form2", , , , , , strOpenArgs

Then you extract them using the split function (if you have A2K onwards - if
not, you can write an A97 version)

strOpenArgs = Nz(Me.OpenArgs)
If Len(strOpenArgs)=0 Then Exit Sub
astrValues = Split(strOpenArgs, "|")
MsgBox "Form Name: " & astrValues(0) & vbCrLf & _
"Contact ID: " & astrValues(1)
Fletcher
Nov 12 '05 #2
On Wed, 11 Feb 2004 09:42:58 +0000 (UTC), "Fletcher Arnold"
<fl****@home.com> wrote:

<clip>
Yes, or better yet use a querystring-like format that is also
self-describing:
<key1>=<value1>&<key2>=<value2>

In VB I use a Scripting.Dictionary object to simulate OpenArgs. Could
probably use that in Access as well.

-Tom.



Have you considered combining more than one piece of information in the
OpenArgs string?

Dim strOpenArgs As String
strOpenArgs = Me.Name & "|" & Nz(Me!ContactID,0)
DoCmd.OpenForm "Form2", , , , , , strOpenArgs

Then you extract them using the split function (if you have A2K onwards - if
not, you can write an A97 version)

strOpenArgs = Nz(Me.OpenArgs)
If Len(strOpenArgs)=0 Then Exit Sub
astrValues = Split(strOpenArgs, "|")
MsgBox "Form Name: " & astrValues(0) & vbCrLf & _
"Contact ID: " & astrValues(1)
Fletcher


Nov 12 '05 #3
"Tom van Stiphout" <to*****@no.spam.cox.net> wrote in message
news:ih********************************@4ax.com...
On Wed, 11 Feb 2004 09:42:58 +0000 (UTC), "Fletcher Arnold"
<fl****@home.com> wrote:

<clip>
Yes, or better yet use a querystring-like format that is also
self-describing:
<key1>=<value1>&<key2>=<value2>

In VB I use a Scripting.Dictionary object to simulate OpenArgs. Could
probably use that in Access as well.

-Tom.

Certainly. Passing a string of "FormName=frmMyForm&ContactID=1024" would
make it a lot clearer than extracting values astrValues(0) and
strValues(1) - which is not very self-explanatory.

Fletcher

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: neblackcat | last post by:
Would anyone like to comment on the following idea? I was just going to offer it as a new PEP until it was suggested that I post it here for comment & consideration against PEP 308. I'm far...
4
by: Steve | last post by:
Hi all I have to validate a password to determine whether or not it adheres to certain rules. For example, the password must contain at least 1 number, at least 1 uppercase character and at...
7
by: Patient Guy | last post by:
Coding patterns for regular expressions is completely unintuitive, as far as I can see. I have been trying to write script that produces an array of attribute components within an HTML element. ...
7
by: mark | last post by:
Access 2000: I creating a report that has a record source built by the user who selects the WHERE values. An example is: SELECT * FROM CHARGELOG WHERE STDATE Between #10/27/2003# And...
17
by: Nick | last post by:
I am doing some research into building web applications using Object Oriented techniques. I have found the excellent patterns section on the MSDN site, but other than that I cannot find any good,...
0
by: Irfan Akram | last post by:
Hello People, I would appreciate your responses on this. I am writing an asp.net web-application involving C#. I am actually building a test hierarchy at the moment, which involves producing...
13
by: Daniel W | last post by:
Hi! I tried to post this to comp.lang.c.moderated but it didn't seem to go through. I've got a question about volatiles in assignment expressions. I found the following code snippet in an...
66
by: Atmapuri | last post by:
Hi! I noticed a very funny behaviour when overloading operators on objects in C#: MyOjbects a,b,c,d; .... //objects are created and initalized here... .... b.Length = 100;
0
by: =?Utf-8?B?VmltYWw=?= | last post by:
Hi, We trying to build IDE like application in ASP.Net by using ASP.Net AJAX control toolkit. And the IDE should support resizing, drag and drop controls. When we place a control (like...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.