Solved

MS ACCESS Default Value help

Posted on 2011-02-13
10
267 Views
Last Modified: 2012-06-21
i have a db in .mde format. form with a field called Truck #, DriverName, StartMiles, etc.....  table where data is stored Drivers_Log... what i want is on the form if i double click on a field it will pop up and say Please Enter Default Value for Truck #. the value u enter will be the default value for that field. so when i cluck on new Record the default value will be what i put in the input box.
0
Comment
Question by:Blueice13085
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34885466
<i have a db in .mde format.> you can't modify this version (.mde)

you have to get the .mdb version to add this feature
0
 

Author Comment

by:Blueice13085
ID: 34885504
well i have the mdb, final will be mde
0
 
LVL 21
ID: 34885512
To expanded on capricorn1's reply;

The MDB is the source database. It has all the VBA source code. You can modify the form, reports, and Modules.  The .MDB is the "master" or  "Source code".

You create an MDE from a MDB. When you compile a  MDB into an MDE file  all the VBA source code is removed. Only the compiled code is left in the new MDE file.

It is very important to keep the MDB file in a safe place.  

If you do not the MDE and do not have the MDB then you might not have permission to make changes
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 21
ID: 34885514
To expanded on capricorn1's reply;

The MDB is the source database. It has all the VBA source code. You can modify the form, reports, and Modules.  The .MDB is the "master" or  "Source code".

You create an MDE from a MDB. When you compile a  MDB into an MDE file  all the VBA source code is removed. Only the compiled code is left in the new MDE file.

It is very important to keep the MDB file in a safe place.  

If you do not the MDE and do not have the MDB then you might not have permission to make changes
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34885519
don'y know why you need it that way, you can set the default value in the design view of the table and/or form.

0
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 500 total points
ID: 34885526
The way I like to handle the default way for a text box is to remember the last enter made.

Is numeric data use:

Private Sub YourTxtboxName_AfterUpdate()
 Me.YourTxtboxName.DefaultValue = Me.YourTxtboxName
End Sub

Open in new window


If test then use:
Private Sub YourTxtboxName_AfterUpdate()
 Me.YourTxtboxName.DefaultValue = Chr(34) & Me.YourTxtboxName & Chr(34)
End Sub

Open in new window


0
 

Author Comment

by:Blueice13085
ID: 34885539
GET A error using this

Private Sub NAME_AfterUpdate()
    Me.NAME.DefaultValue = Chr(34) & Me.NAME & Chr(34)
End Sub
0
 
LVL 21
ID: 34885714
Name is actually  a property of the control and should not be used as the control's name

I would change the control's name to be txtName.

You could also try this:

Private Sub NAME_AfterUpdate()
    Me.[NAME].DefaultValue = Chr(34) & Me.[NAME] & Chr(34)
End Sub

Open in new window




0
 

Author Comment

by:Blueice13085
ID: 34916940
no that still didn't work , guess i will have to do the long process of changing the name to driver or something like that just means i have to change it in every form, report, & query
0
 
LVL 21
ID: 34919611
The issue is not with the field name in the table but with the control name for the text box.

You do not have to change the field  name int eh table.

Try a test on just one form: change the text box 's  Name property  to something like txtDriverName.  

Then try the code:
Private Sub NAME_AfterUpdate()
    Me.[txtDriverNAME].DefaultValue = Chr(34) & Me.[txtDriverNAME] & Chr(34)
End Sub

Open in new window


When you edit the forms to make this change you would also rename the control at the time.  You would only have to do this on the forms where you want to set the default value.  You do not have to change any reports or queries since they will not need the VBA code to set the default value.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question