Setting a value of a field equal to another automatically in a form

C

Chris

I'm trying to set values equal to that of another field already entered in a
form. Any quick and easy ideas on how to do that?

Thanks
Chris
 
A

Arvin Meyer

Chris said:
I'm trying to set values equal to that of another field already entered in a
form. Any quick and easy ideas on how to do that?

Use a bit of code in an Event procedure in the first text box's AfterUpdate
event. Something like:

Sub txtOne_AfterUpdate()
Me.txtTwo = Me.txtOne
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
J

John Vinson

I'm trying to set values equal to that of another field already entered in a
form. Any quick and easy ideas on how to do that?

Thanks
Chris

First ask if you need to be storing data redundantly AT ALL. What are
these two fields? Is the second field ALWAYS equal to the first? If
so, it should not exist; just display the one field twice in two
different textboxes.

If the default value of the second field is equal to the first, but it
can be changed, you can put some code in the first textbox's
AfterUpdate event:

Private Sub txtFirst_AfterUpdate()
If IsNull(Me!txtSecond) Then ' don't step on existing data
Me!txtSecond = Me!txtFirst
End If
End Sub

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
C

Chris

Well,
This was the first half to a 2-part question. I am designing a
database to use as a logbook for my flying. This DB will have 2 tables (so
far). The first table contains information about the aircraft I fly. This
includes the tail number (unique), horsepower, if the airplane is high
performance and/or complex.

The second table has various fields to hold number of hours logged in that
flight. If I select an aircraft that is high performance and complex, I want
to have the HighPerf and Cmplx fields have values equal to the
'SingleEngine' time.

I hope this makes sense.

Thanks though!

Chris
 
C

Chris

I've copied that text into the event procedure, replaceing me and
txtTwo/txtOne with actual table and field names, but I still get the 'Object
Required' error.

Any ideas?
 
J

John Vinson

The second table has various fields to hold number of hours logged in that
flight. If I select an aircraft that is high performance and complex, I want
to have the HighPerf and Cmplx fields have values equal to the
'SingleEngine' time.

I hope this makes sense.

No. It doesn't.

The fact that an aircraft is high performance is an attribute *OF THE
AIRCRAFT*. It is not an attribute of a logged hour.

Just store the aircraft ID in the log table, and use a Query to look
up these fields from the aircraft table. There is no need or benefit
to store these values redundantly in the log table.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
C

Chris

John Vinson said:
No. It doesn't.

The fact that an aircraft is high performance is an attribute *OF THE
AIRCRAFT*. It is not an attribute of a logged hour.

Just store the aircraft ID in the log table, and use a Query to look
up these fields from the aircraft table. There is no need or benefit
to store these values redundantly in the log table.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps

Well, that might be your opinion but was the way we wanted to try to do it.

I know I could query the table, based on an aircraft ID, and find out how
many hours of a specific type there are. This however, makes it more
difficult to ever view the data in a spreadsheet form. It is also very
possible to have the entire table exported to a user.

I'm open to other suggestions.
 
J

John Vinson

Well, that might be your opinion but was the way we wanted to try to do it.

I know I could query the table, based on an aircraft ID, and find out how
many hours of a specific type there are. This however, makes it more
difficult to ever view the data in a spreadsheet form. It is also very
possible to have the entire table exported to a user.

I'm open to other suggestions.

<shrug>

If you assume that you must have the data in a table to export it or
view it as a datasheet (not that I would ever recommend using
datasheets for routine viewing), your assumption is incorrect. But if
you insist...


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 

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