Carrying over data between fields

P

ProdTech

How can I design a Form which will take certain data and carry it over to the
next new form? Example: I am a production worker who is entering
information on scrapped parts. My production run was 100 units, 15 of which
were scrapped.
I need to enter my employee number once only, as well as the job number and
part number, while all other information is specific to each scrapped part,
such as part serial number, and reason for scrapping.
 
A

Arvin Meyer [MVP]

Here is an expression that I found that worked for setting the defaultvalue
for the country field using the Customers table (NorthWind sample
database)...

Me!Country.DefaultValue = """" & Me!Country.Value & """"

That's 4 double quotes on either side. I put it in the AfterUpdate event of
the Country textbox. It should work for all datatypes.
 
P

ProdTech

Putting that code, with the actual field name substituted in gives me an
error stating that the Object does not contain the automation object 'Me.'
 
P

ProdTech

Perhaps I should clarify: my workers need to be able to start by entering
their employee number, which will become the default entry in the field
"Employee Number" for the duration of their session. Then they need to enter
a job number and part number which will be the default "job number" and "part
number" values until they decide to change them. After all of this, they
need to enter the individual serial number and other data for the specific
part which they are reporting.
 
P

ProdTech

Ok, so let me see if I'm understanding this syntax correctly. Most of my
programming experience is in C++, not VBA or SQL, so I think I'm suffering
some knowledge fusion:

Me!Country represents the 'Country' field in the current open form,
regardless of the name. Or should "Me" be replaced with the form name?
..txtwhatever - not quite sure what this part of the variable does.

= """" & Me!txtWhatever.Value & """" is storing in the above variable, the
text string found in txtWhatever.Value, in the current open form,
concatenated with two sets of double quotes on each side, the purpose of
which I'm not sure of.

One would think there would be a simple selection somewhere to tell Access
not to clear the field when I create a new record, but I'm not complaining, I
didn't design it.
 
A

Arvin Meyer [MVP]

Sorry, I had a sample from Northwind and neglected to edit properly. I
should be:

Private Sub txtWhatever_AfterUpdate()
Me!txtWhatever = """" & Me!txtWhatever.Value & """"
End Sub

Me is the current open form or report. It replaces: Forms!FormName so you
can use:

Me.MyForm.MyControl

or:

Forms!MyForm!MyControl

interchangeably. The . or ! are also interchangeable in this context
(recordsets only use !), but using the . allows intellisense to help choose.

txtWhatever is the controlname of the textbox which houses the field (fields
are columns in a table or query, controls are objects on forms and reports
which can be bound to those fields)

Using 4 double quotes on each side tells Access that the control accepts
text, numeric, or date datatypes
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
T

Tim Shepherd

Arvin,

I've tried using your suggestion but I don't seem to be using it correctly.
For a date field, I've entered:
Private Sub txtSurveyDate_AfterUpdate()
Me![txtSurveyDate].DefaultValue = "" & Me![txtSurveyDate].Value & ""
End Sub

It sends the value to the default setting, but "#" is missing from around
the data. The Default gets show as "12/30/1899" in the new record. With
entering the experssion for a text field, the quote marks around the text are
left out.

Assistance greatly appreciated,
Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top