473,395 Members | 1,532 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.

Referencing Form fields

Hi,

I am facing an unusual issue with my Access 2016 VBA code.

I have a Form with a field called txtUID. I'm using the Form_Load sub to initialize this field as follows:
Expand|Select|Wrap|Line Numbers
  1. Me.txtUID.Value  Format(Date, "dd/mm/yyyy")
In a separate module sub, when i use this...
Expand|Select|Wrap|Line Numbers
  1. tmpTimeStampUID = Me.txtUID.Value
, i get the error INVALID USE OF 'ME' KEYWORD.

If i delete the Me and keep
Expand|Select|Wrap|Line Numbers
  1. tmpTimeStampUID = txtUID.Value
, i get the error MISSING OBJECT

What am i doing wrong?? Please help.
Sep 10 '18 #1
2 5327
PhilOfWalton
1,430 Expert 1GB
The word "me" can only be used in a form or report's module, and obviously is a shorthand way of referring to that form or report.

In an external module, you must refer to the form or report by name
So
Expand|Select|Wrap|Line Numbers
  1. tmpTimeStampUID = Forms!MyFormName!txtUID.Value
where MyFormName is the name of your form.

I rarely find the word "Value" is needed, so try without it.

Phil
Sep 10 '18 #2
NeoPa
32,556 Expert Mod 16PB
Hi mshriyan.

As Phil says, Me is a reference to the current Form/Report object and as such, can never be used unless within the linked module of a Form/Report. Obviously, whichever object's module it's used within is the object that Me refers to.

.Value is the default property for Controls so is not usually needed in such code. It can't hurt to be explicit but it's usually abbreviated.

A Control on a Form or Report is a Control and not a Field. Controls may be bound to Fields from the Form's RecordSource but they are by no means synonymous.

As Phil says, when a Form/Report is referenced outside of its own linked module then you need some other way of referencing that object. There are a million and one different ways but in most circumstances his example will work for you. The Form/Report would need to be open already mind you, but I would guess that's the case in your situation.
Sep 10 '18 #3

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

Similar topics

3
by: TG | last post by:
I have a form that POSTs to itself and validates data entered into the form. If all is well the form performs a header location command to move to the next input form in the series. If the user has...
4
by: bnp | last post by:
Hi All, I am quite new the JavaScript. Basically I am a C++ programmer, but now I am working on JavaScript since last 5 days. I have a problem regarding the form validation. I have created a...
4
by: karenmiddleol | last post by:
I have the following form the user enters the From and to period and presses the Submit button and the form fields are cleared once the submit button is pressed. Is there a way I can keep the...
4
by: mplogue | last post by:
I have a form (frmMain) with a subform (frmSub), each with enumerated fields of the same name (txt1, txt2, etc). I'm trying to make a function that will take the values for each field in frmMain,...
7
by: Chuck Anderson | last post by:
I'm pretty much a JavaScript novice. I'm good at learning by example and changing those examples to suit my needs. That said .... ..... I have some select fields in a form I created for a...
7
by: Perks | last post by:
Hi. I am trying to find out if it is possible to open a pdf file from within PHP, and parse its contents in order to extract all form fieldnames that might have been previously setup within the...
4
by: Mike De Petris | last post by:
I am using itextsharp to fill in and flatten some fields from data filled in a web form field and all works quite well. The question now is how to manage the pdf template that has the fields to...
3
by: wparrott | last post by:
Hello everyone, I'm trying add a print button that opens a Word document and fills in form fields in the document based on the currently displayed record. The code works in a sample that I ran but...
1
by: Rick Owen | last post by:
Greetings, I have a form that, when submitted, calls a plsql procedure. The form has a number of fields (text, hidden, select, radio) but the particular field that is giving me problems is a...
1
sbouley7
by: sbouley7 | last post by:
I've been working with VBA in access for a while but there's been one thing I never could get the hang of. I'm trying to update a record in VBA. The value to update and the criteria are contained...
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:
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.