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

Setting the Default Value of a Control on Form Open

I'm trying to make a dialog box pop up and ask the User for their name when they open a particular form. I then want to set the default value of a text box called "EnteredBy" to their name. However the only thing that ever appears in the text box is "#Name?" I don't know what I'm doing wrong. Can somebody please help with the code that I'm missing?

So far, in my declarations I have:

Expand|Select|Wrap|Line Numbers
  1. Dim varUserName as String
  2.  
Then on Form Open I run the following command:

Expand|Select|Wrap|Line Numbers
  1. varUserName = inputBox(Please enter your name) 'Prompts user for their name and stores it in the variable varUserName.
  2.  
  3. MsgBox (varUserName) ' Displays the value of varUserName
  4.  
  5. Me![EnteredBy].defaultvalue = varUserName
  6.  
The inputBox and MsgBox funstions work properly and store the string, but for some reason I can't set the default value property control. Any help is appreciated.

Ed
Sep 29 '10 #1
1 5365
Stewart Ross
2,545 Expert Mod 2GB
Hi. The defaultvalue property is a text value. As you are setting it as a string literal you will need to enclose that value in quotes:

Expand|Select|Wrap|Line Numbers
  1. Me![EnteredBy].defaultvalue = "'" & varUserName & "'"
-Stewart
Sep 29 '10 #2

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

Similar topics

2
by: JC Mugs | last post by:
I have a form and wish to keep the date entry from form to form.. Found code that follows that says it should work in an afterupdate event. Private Sub IDate_AfterUpdate() Me!IDate.Default =...
11
by: David Messner | last post by:
Ok I know this is simple but the statement eludes me... I have a date field where I want the default value on the data entry form's date field to be the last date entered. I figure I can do this...
2
by: hyphen | last post by:
I have set up two date fields in a table: 1stpromisedDate and CurentPromisedDate The first field is to record the 1st promised delivery date of a supplier and the second is to record the...
0
by: Darren Clark | last post by:
I am trying to set the default value (not mistaken for NULL value) for a datetime element of a typed dataset. <xs:element name="create_date" type="xs:dateTime"...
3
by: Barbara Lindsey | last post by:
I have a case where I am collecting a "Start Date" and an "End Date". I would like to default the "End Date" to the "Start Date" value if only the "Start Date" is entered. I tried setting this as...
0
by: cefrancke | last post by:
I would like to set a default value for a field in a datatable in the data designer. The "default" value for the default column is "<DBNull>". I'm using CSharp, but I would like to simply put a...
1
by: Will | last post by:
I am upsizing an access application to vb.net. In access textbox, combos and checkboxes can have default values, which are assigned in the properties for the control. How can I set a control's...
0
by: miketayloruk | last post by:
I'm using a detailsview control that I want to use to insert data to a table. One of the fields is a date field and I want that to default to todays date. In classic asp I would do it like this: ...
2
kmartinenko
by: kmartinenko | last post by:
Hi everyone, I have several combo boxes on my form, and while I have designated a column head, I cannot figure out how to default to the column head value. What I really want is for all of my...
5
by: MNNovice | last post by:
My combo box is pulling data from tblAccounts using its PK (auto number) AccountID but displaying AccountNo (text). Is it possible to set the default value for this combo box to one of the...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.