A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Extract value from specific record to populate a new record



 
 
Thread Tools Display Modes
  #1  
Old November 12th, 2009, 09:31 PM posted to microsoft.public.access.forms
Eddie B[_2_]
external usenet poster
 
Posts: 2
Default Extract value from specific record to populate a new record

sHi,
Not really sure how to get my question across. I am using Office 2007. I
have a form that consists of a Drop box(which displays a license plate
numbers) and other fields with vehicle information ie. "miles out" and "miles
in". This form populates a dispatch info table. When I choose a license plate
number for a new record I would like the "miles in" field to auto fill with
the last "miles in" value corresponding to the license plate number chosen.
any help would be greatly appreciated.
  #2  
Old November 13th, 2009, 03:06 AM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Extract value from specific record to populate a new record

"Eddie B" Eddie wrote in message
...
sHi,
Not really sure how to get my question across. I am using Office 2007. I
have a form that consists of a Drop box(which displays a license plate
numbers) and other fields with vehicle information ie. "miles out" and
"miles
in". This form populates a dispatch info table. When I choose a license
plate
number for a new record I would like the "miles in" field to auto fill
with
the last "miles in" value corresponding to the license plate number
chosen.
any help would be greatly appreciated.



I assume that by "drop box" you mean a combo box. To answer your question,
I need answers to some questions of my own:

1. What is the name of the table that contains the vehicle information,
including the license plate number, miles in, and miles out?

2. What are the names of those fields in the table?

3. Do you really want to auto fill the "miles in" field with the vehicle's
last "miles in", or is it the "miles out" field that you want to fill?

4. How do you determine what is the *last* "miles in"? Is it the highest
number?

5. I'm guessing these are odometer readings. If the last "miles in" is the
highest one, might you ever have to deal with an odometer that has rolled
over from its maximum reading to zero again?

--
Dirk Goldgar, MS Access MVP
Access tips:
www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #3  
Old November 13th, 2009, 03:37 AM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Extract value from specific record to populate a new record

"Dirk Goldgar" wrote in message
...


I assume that by "drop box" you mean a combo box. To answer your
question, I need answers to some questions of my own:

1. What is the name of the table that contains the vehicle information,
including the license plate number, miles in, and miles out?

2. What are the names of those fields in the table?

3. Do you really want to auto fill the "miles in" field with the vehicle's
last "miles in", or is it the "miles out" field that you want to fill?

4. How do you determine what is the *last* "miles in"? Is it the highest
number?

5. I'm guessing these are odometer readings. If the last "miles in" is
the highest one, might you ever have to deal with an odometer that has
rolled over from its maximum reading to zero again?



Oops, forgot:

6. What is the name of the combo box?


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #4  
Old November 13th, 2009, 12:32 PM posted to microsoft.public.access.forms
Eddie B
external usenet poster
 
Posts: 6
Default Extract value from specific record to populate a new record

Thank you for the reply.
Yes, the "drop box" is actually a combo box.

1. Table name is "dispdetails.
2. Field names are "tagnumber" "milesout" "milesin"

3. You are correct in that I want the miles out filled in with the last
miles in for that tagnumber.

4. yes, it would be the highest number for that tagnumber.

5. yes, these are odometer readings. there is no chance of having to deal
with an odometer that has rolled over.

6. The combo box name is "vehiclebox"

Thanks again

"Dirk Goldgar" wrote:

"Dirk Goldgar" wrote in message
...


I assume that by "drop box" you mean a combo box. To answer your
question, I need answers to some questions of my own:

1. What is the name of the table that contains the vehicle information,
including the license plate number, miles in, and miles out?

2. What are the names of those fields in the table?

3. Do you really want to auto fill the "miles in" field with the vehicle's
last "miles in", or is it the "miles out" field that you want to fill?

4. How do you determine what is the *last* "miles in"? Is it the highest
number?

5. I'm guessing these are odometer readings. If the last "miles in" is
the highest one, might you ever have to deal with an odometer that has
rolled over from its maximum reading to zero again?



Oops, forgot:

6. What is the name of the combo box?


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #5  
Old November 13th, 2009, 01:53 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Extract value from specific record to populate a new record

"Eddie B" wrote in message
...
Thank you for the reply.
Yes, the "drop box" is actually a combo box.

1. Table name is "dispdetails.
2. Field names are "tagnumber" "milesout" "milesin"

3. You are correct in that I want the miles out filled in with the last
miles in for that tagnumber.

4. yes, it would be the highest number for that tagnumber.

5. yes, these are odometer readings. there is no chance of having to deal
with an odometer that has rolled over.

6. The combo box name is "vehiclebox"



Based on this info, you could use the following event procedure for the
AfterUpdate event of the combo box:

'------ start of code ------
Private Sub vehiclebox_AfterUpdate()

If Not IsNull(Me.vehiclebox) Then

Me.milesout = _
DMax("milesin", "dispdetails", _
"tagnumber = '" & Me.vehiclebox & "'")

End If

End Sub
'------ end of code ------

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #6  
Old November 13th, 2009, 05:47 PM posted to microsoft.public.access.forms
Eddie B
external usenet poster
 
Posts: 6
Default Extract value from specific record to populate a new record

I copied and pasted the code in the AfterUpdate event of the combo box. For
some reason I am getting a Run Time error 3646 Type Data Mismatch In
Criteria Expression. Any ideas what I am doing wrong.

"Dirk Goldgar" wrote:

"Eddie B" wrote in message
...
Thank you for the reply.
Yes, the "drop box" is actually a combo box.

1. Table name is "dispdetails.
2. Field names are "tagnumber" "milesout" "milesin"

3. You are correct in that I want the miles out filled in with the last
miles in for that tagnumber.

4. yes, it would be the highest number for that tagnumber.

5. yes, these are odometer readings. there is no chance of having to deal
with an odometer that has rolled over.

6. The combo box name is "vehiclebox"



Based on this info, you could use the following event procedure for the
AfterUpdate event of the combo box:

'------ start of code ------
Private Sub vehiclebox_AfterUpdate()

If Not IsNull(Me.vehiclebox) Then

Me.milesout = _
DMax("milesin", "dispdetails", _
"tagnumber = '" & Me.vehiclebox & "'")

End If

End Sub
'------ end of code ------

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #7  
Old November 13th, 2009, 06:14 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Extract value from specific record to populate a new record

"Eddie B" wrote in message
...
I copied and pasted the code in the AfterUpdate event of the combo box. For
some reason I am getting a Run Time error 3646 Type Data Mismatch In
Criteria Expression. Any ideas what I am doing wrong.


What data type is the field "tagnumber" in table "dispdetails"? I assumed
it was text; if it's a number type then the code should be:

Me.milesout = _
DMax("milesin", "dispdetails", _
"tagnumber = " & Me.vehiclebox)


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #8  
Old November 16th, 2009, 03:29 PM posted to microsoft.public.access.forms
Eddie B
external usenet poster
 
Posts: 6
Default Extract value from specific record to populate a new record

It worked like a charm. Thank you very much for your help

"Dirk Goldgar" wrote:

"Eddie B" wrote in message
...
I copied and pasted the code in the AfterUpdate event of the combo box. For
some reason I am getting a Run Time error 3646 Type Data Mismatch In
Criteria Expression. Any ideas what I am doing wrong.


What data type is the field "tagnumber" in table "dispdetails"? I assumed
it was text; if it's a number type then the code should be:

Me.milesout = _
DMax("milesin", "dispdetails", _
"tagnumber = " & Me.vehiclebox)


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:11 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.