how to take a value from one form to anothor (1 Viewer)

sspreyer

Registered User.
Local time
Today, 11:28
Joined
Nov 18, 2013
Messages
251
vbainet worked you Legend!!!!!
thanks again
shane
 

sspreyer

Registered User.
Local time
Today, 11:28
Joined
Nov 18, 2013
Messages
251
hi i have now found problem
on close it takes the value from the first entered record and adds it to the serviceduedate but i want it to take the last record value and add it to service date if this make sence

cheers

shane
 

vbaInet

AWF VIP
Local time
Today, 19:28
Joined
Jan 22, 2010
Messages
26,374
It will take the value of record you were last on, not the first record. If you were on the first record, then that's the value it will take.
 

sspreyer

Registered User.
Local time
Today, 11:28
Joined
Nov 18, 2013
Messages
251
It will take the value of record you were last on, not the first record. If you were on the first record, then that's the value it will take.

it defo taking the first record it doesnt matter what one i click on and close
always take first record :(
 

vbaInet

AWF VIP
Local time
Today, 19:28
Joined
Jan 22, 2010
Messages
26,374
When I say on, I mean the record you click, not just the record you scroll down to view. So let's see if you can work this one out yourself, you will need two functions but start of with the DMax function (link below). Get the highest (or max) value of the unique ID in the query or table that's bound to the form:

http://www.techonthenet.com/access/functions/domain/dmax.php
 

sspreyer

Registered User.
Local time
Today, 11:28
Joined
Nov 18, 2013
Messages
251
hi

here's a sample database I can't understand why it always takes the first record and transfer it but the focus is set to the last record which I want it to transfer very weird I thought it would transfer they last record date

cheers

shane

can any one see a problem cheers :banghead::banghead::banghead::banghead:
View attachment shanetest2.zip
 

sspreyer

Registered User.
Local time
Today, 11:28
Joined
Nov 18, 2013
Messages
251
hi right this is what I have tried but doesn't seem to be working
Code:
DMax("[ServiceDate]","[PlantServiceTbl]","([serviceid]= " & [PlantServiceTbl] & ")")

see what you think

cheers

shane
 

vbaInet

AWF VIP
Local time
Today, 19:28
Joined
Jan 22, 2010
Messages
26,374
Test it with a MsgBox. It's a good way for beginners to test things. There are other ways, but let's stick with this one first.

Code:
Msgbox DMax("[ServiceDate]","[PlantServiceTbl]", [COLOR="Blue"]"[/COLOR][serviceid]= " & [PlantServiceTbl][COLOR="blue"])[/COLOR]
I hope you notice the changes
 

sspreyer

Registered User.
Local time
Today, 11:28
Joined
Nov 18, 2013
Messages
251
ok..

its now saying the expression you have entered is a invalid syntax
it highlights Dmax

Code:
 Msgbox [COLOR=red][B]DMax[/B][/COLOR]("[ServiceDate]","[PlantServiceTbl]", "[serviceid]= " & [PlantServiceTbl])

cheers

shane
 

vbaInet

AWF VIP
Local time
Today, 19:28
Joined
Jan 22, 2010
Messages
26,374
My bad:
Code:
Msgbox DMax("[ServiceDate]","[PlantServiceTbl]")
 

vbaInet

AWF VIP
Local time
Today, 19:28
Joined
Jan 22, 2010
Messages
26,374
But ServiceDate can't be the field you want to return the max of anyway.
 

sspreyer

Registered User.
Local time
Today, 11:28
Joined
Nov 18, 2013
Messages
251
no thats my next question

its service next due which is a calculated field called DateDue

but this expression will not work :confused:

Code:
Msgbox DMax("[datedue]","[PlantServiceTbl]")

as it not in my table its a calculated field :confused:

cheers

shane
 

vbaInet

AWF VIP
Local time
Today, 19:28
Joined
Jan 22, 2010
Messages
26,374
What is the sequential Number ID field that is unique in table?
 

sspreyer

Registered User.
Local time
Today, 11:28
Joined
Nov 18, 2013
Messages
251
serviceId is the primary key
impPlantitemId is the Plant item id the link between plant item and plant service

if this helps

thanks

shane
 

vbaInet

AWF VIP
Local time
Today, 19:28
Joined
Jan 22, 2010
Messages
26,374
And ServiceID increments automatically right? So what do the three parameters in the DMax function represent?
Code:
DMax(first part, second part, third part)
first part - the field that you want to get the highest number of
second part - the table or query where this field is
third part - criteria part if you want to filter based on certain conditions. In your case you don't need this part here.

So from what I just explained what should be your first and second parts?
 

sspreyer

Registered User.
Local time
Today, 11:28
Joined
Nov 18, 2013
Messages
251
right...
ServiceID increments automatically right? answer yes

first part: datedue
second part: plantservicetbl subform : query builder

thanks

shane
 

vbaInet

AWF VIP
Local time
Today, 19:28
Joined
Jan 22, 2010
Messages
26,374
Please re-read my last post.

first part - the field that you want to get the highest number of

Is DateDue the field you want to get the highest number of?
 

sspreyer

Registered User.
Local time
Today, 11:28
Joined
Nov 18, 2013
Messages
251
Right ....

Yes I want to get highest date from datedue this is calculated field in my query

So it would be

First part the

field = datedue

Second part is

Query name = qtyplantservice

Thanks

Shane
 

vbaInet

AWF VIP
Local time
Today, 19:28
Joined
Jan 22, 2010
Messages
26,374
Upload a copy of your db and tell me where to look.
 

Users who are viewing this thread

Top Bottom