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

Access 97 - Passing a field value to another form

Hi,

I need to pass the value held in a field in one form and have it
appear in another form. I specifically don't want to have to refer to
the original form name as it has passed, because I want the second
form to be accessed from several different places.

I've tried declaring a public variable:

Public gempID As Integer

at the top of the module for the first form,
but the field in the second form then just displays #Name?, even
though the name in the second form is exactly the same as the name of
the variable.

Any suggestions?
Regards,
Bernard D
Nov 13 '05 #1
5 8125
"Bernard Davis" <bdavis(deletethis)@castlecs.co.uk> wrote in message
news:99********************************@4ax.com...
Hi,

I need to pass the value held in a field in one form and have it
appear in another form. I specifically don't want to have to refer to
the original form name as it has passed, because I want the second
form to be accessed from several different places.

I've tried declaring a public variable:

Public gempID As Integer

at the top of the module for the first form,
but the field in the second form then just displays #Name?, even
though the name in the second form is exactly the same as the name of
the variable.


I think you'd need to declare a Global variable in a module.

Regards,
Keith.
www.keithwilby.com
Nov 13 '05 #2
On Thu, 5 May 2005 15:54:29 +0100, "Keith"
<ke*********@baeAWAYWITHITsystems.com> wrote:
"Bernard Davis" <bdavis(deletethis)@castlecs.co.uk> wrote in message
news:99********************************@4ax.com.. .
Hi,

I need to pass the value held in a field in one form and have it
appear in another form. I specifically don't want to have to refer to
the original form name as it has passed, because I want the second
form to be accessed from several different places.

I've tried declaring a public variable:

Public gempID As Integer

at the top of the module for the first form,
but the field in the second form then just displays #Name?, even
though the name in the second form is exactly the same as the name of
the variable.


I think you'd need to declare a Global variable in a module.


Thanks, yes I know that.
Public = Global (as far as I know).

The problem is I've tried that as well,
Public gempID As Integer
at the top of a module called PublicVariables.

I can then assign a value to that variable, but it is ignored in the
second form.

What I'm trying to do is allow the user to create notes about a record
and I need to pass the record ID so that the notes will refer back to
the correct record subsequently.
I can explicitly refer to the ID by using the originating form name -
and that works, but as the notes form can be called from a number of
different places I don't want to have to keep building notes forms,
each one of which refers explicitly to the originating form (if that
makes sense).

Regards,
Bernard D

Nov 13 '05 #3
"Bernard Davis" <bdavis(deletethis)@castlecs.co.uk> wrote in message
news:k7********************************@4ax.com...

I think you'd need to declare a Global variable in a module.


Thanks, yes I know that.
Public = Global (as far as I know).

The problem is I've tried that as well,
Public gempID As Integer
at the top of a module called PublicVariables.

I can then assign a value to that variable, but it is ignored in the
second form.

Public, Global, whatever :o) the point is that it needs to be in a module
and you need to:

1 - Set the variable using your first form (you seem to know that already);
2 - Set the control on the second form as appropriate.

I just tried it by setting the Public/Global variable in a form's On Open
event and then retrieving it via a second form's On Current event and it
worked fine:

Private Sub Form_Current()

Me.txtMyTextBox = gempID

End Sub

I've just re-read the last bit of your post and it seems that what you're
trying to do could be done for free by Access by setting up a query
containing the tables for both forms - they must be related, surely?

Regards,
Keith.
Nov 13 '05 #4
When you want to open the second form, from say a button click, use
code like this on the button in the first form:

DoCmd.OpenForm stDocName, acNormal, , , , , Me.boxFID

Where stDocName is the name of the second form and Me.boxFID is the
field that contains the value you want to pass.
The commas are all needed, they are for different options when opening
a form.

Then use code like this in the 'on open' event of the second form:

If Not IsNull(Me.OpenArgs) Then
Me.boxFinder.Value = Me.OpenArgs
Me.Requery
End If

Me.OpenArgs will be equal to whatever value you passed from the event
in the first form.

Nov 13 '05 #5
On 5 May 2005 11:48:08 -0700, "Nunya Biznas" <Nu*********@comcast.net>
wrote:
When you want to open the second form, from say a button click, use
code like this on the button in the first form:

DoCmd.OpenForm stDocName, acNormal, , , , , Me.boxFID

Where stDocName is the name of the second form and Me.boxFID is the
field that contains the value you want to pass.
The commas are all needed, they are for different options when opening
a form.

Then use code like this in the 'on open' event of the second form:

If Not IsNull(Me.OpenArgs) Then
Me.boxFinder.Value = Me.OpenArgs
Me.Requery
End If

Me.OpenArgs will be equal to whatever value you passed from the event
in the first form.

Many thanks, this was the clue I needed. It now works perfectly. The
real problem was that I was opening this second form from about 12
different places and couldn't face having to create 12 different
versions of it.

Regards,

Bernard D
Nov 13 '05 #6

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

Similar topics

12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
1
by: Kevin Lyons | last post by:
Hello, I am trying to get all of my form elements passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html to the following URL:...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
55
by: AnandaSim | last post by:
I just had a google through this NG but have not seen mention of Erik Rucker's blog entry and the new Jet: http://blogs.msdn.com/access/archive/2005/10/05/477549.aspx mentioned by Mike...
2
by: Michael Bialowas | last post by:
Hello all, I have been searching the net endlessly and found this ng, so I thought I would give a try. Anyways, I have a few problems I am trying to implement a combo box which presently contains...
5
by: effendi | last post by:
I am trying to write a simple routine multiplying one value of a field to another. i.e cost1 multiple by cost2.. But since I have many lines of these, I want to write a function by accessing the...
10
by: Les Desser | last post by:
In article <fcebdacd-2bd8-4d07-93a8-8b69d3452f3e@s50g2000hsb.googlegroups.com>, The Frog <Mr.Frog.to.you@googlemail.comMon, 14 Apr 2008 00:45:10 writes Not sure if I quite follow that. 1....
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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: 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.