473,406 Members | 2,843 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,406 software developers and data experts.

Reference to current field on a form

MS Access 2000-
I have a table with 200 fields named F001 through F200
and a form to collect data for those fields. I need to
execute an event procedure On Exit to do a conversion ie.

Expand|Select|Wrap|Line Numbers
  1. Private Sub F001_Exit(Cancel As Integer)
  2.     If Me![F001].Value = "1" Then
  3.         Me![F001].Value = "A"
  4.     ElseIf Me![F001].Value = "2" Then
  5.         Me![F001].Value = "D"
  6.     ElseIf Me![F001].Value = "3" Then
  7.         Me![F001].Value = "U"
  8.     End If
  9. End Sub
  10.  
Is there a way to reference the current field in this
procedure so that one procedure will work for all
fields (F002, F003, ... F200) so I can copy and paste
the procedure rather than replace the field name in
each of the 200 fields ie. instead of using
Me![F00x].Value is there a reference to the current
field that would work in all the fields?

Any suggestions will be greatly appreciated.
Sep 12 '06 #1
3 16766
PEB
1,418 Expert 1GB
Hi,

Type your conversion as a function! Like:

Function my_conversion(my_field)

if my_field=1 then
my_conversion="A"
end if
and so on...

End function

Have a nice day!

:)
Sep 13 '06 #2
Thank you very much for the response. Yes, I can accomplish the same thing with either a function or with a 'Sub' code procedure but the only way I can do either is with a reference to the field name. In order to pass the field parameter to the function, I must use the field name as in:
Function my_conversion(FieldA)
To do this for FieldB, I must pass that field name as the parameter ie.
Function my_conversion(FieldB) and so on
This is fine for a few fields but for hundreds of fields, it would be much easier if I could just reference the current field, whatever that field's name may be.

For example, a reference to the current form is:
Me![ProdID] - where Me references whatever form you are currently in
which can be used as a 'shortcut' in place of [Forms]![Products]![ProdID]
and that will work to reference the field ProdID in any current form.

Is there any such 'shortcut' or symbolic reference that means "current field" so that a function or event 'Sub' procedure can be coded referring to whatever field you are currently working with.

Or am I just missing the point entirely. My function
Function CvtNum(F001)
works to return the correct conversion to the field named F001
but to use that same function with the field named F002, I have to
change the parameter to
Function CvtNum(F002)

in the On Exit event line I am using
=CvtNum(F001)
for the field named F001 and it works but if I copy and paste that same line to the On Exit event line for the field named F002 it does not work. If I try to pass a parameter other than the actual field name, it returns an error that the parameter is an invalid field name.

In looking for a reference or term meaning "current field" am I just wishing for something that doesn't exist? Again, any help or ideas will be greatly appreciated. Thanks.
Sep 28 '06 #3
PEB
1,418 Expert 1GB
Hi,

Try

Application.Screen.ActiveDatasheet.Form.Recordset. ActiveControl

This one works for the queries...

For the forms You have to try it! If it works pls tell me!

Thanks

:)
Sep 30 '06 #4

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

Similar topics

4
by: M Wells | last post by:
Hi All, Is it possible to dynamically determine the current field element in a form? I ask because I have a 'tab' button on a form, and when a user clicks on it I need to be able to shift the...
1
by: John Good | last post by:
Hi I use the Datagrid webcontrol on my web page, and I use the following client-side javascript to duplicate the current row to the datagrid. But when I loop through the data in datagrid from...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
3
by: tsteinke | last post by:
What is the syntax to refer to your current row in an SQL statement? I am using the "Lookup Wizard" to build a query in a table. How do you refer to the Current Row For instance I have a Table...
18
by: klawiter | last post by:
Greetings, I would like to change the background color of fields as they are entered for editing. (then, of course, change them back on exit) My prototype consists of using a couple of global...
3
by: SAL | last post by:
I am getting the following ERROR in my WebApp on line 30: Server Error in '/TestWebApp' Application. -------------------------------------------------------------------------------- Object...
5
by: christianlott1 | last post by:
I admit my form is pretty complex and may need a total overhaul - I have two subforms synchronized on a form through an unbound text box. When I enter a new record in the second subform it used...
9
by: Brad Pears | last post by:
I have the following code that references a "textbox" on a form. I want to pass the value of this textbox to a stored procedure as a parameter. This code is located on a different form obviously. I...
7
by: rleepac | last post by:
My db has a table called M_Employees with the employee demographics. Then I have a table called M_TestsAudio with audiogram results. These two tables are linked by the employee's SSN. Now for my...
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: 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: 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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.