Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2009, 02:23 PM
Registered User
 
Join Date: Jan 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Access 2003

Have a table "tblData" and have a form frmDaily which in certain controls value is calculated with a Dlookup function from a tblREGMTOW when enter certain value in a control cmbRegistartion.

How can I lock (keep) the values calculated in the past in the form and do not alter even if we change the data in tblRegmtow.

i.e.
FORM
I enter a value in cmbRegistration which is stored in tblDATA, control MTOW picks the value with a Dlookup function from tblREGMTOW.

several dates later MTOW in tblREGMTOW has to change

Here comes the problem all form viewed MTOW's are changed to the new value even in the past, (How can I do That without adding a field MTOW int tblData to store the past values.



Thx
AA
 
Old January 29th, 2009, 04:13 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You didn't post the code, but you could enclose it in:

If IsNull(Me.MyControl) Or Me.MyControl = "" (or Me.MyControl = 0 if it is a number) Then

'do dLookUp function

End If

You can put this on the On Current event, and the Before Update event, or where ever the code appears. Can you post it if you need more help?
__________________
mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old January 29th, 2009, 04:25 PM
Registered User
 
Join Date: Jan 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by mmcdonal View Post
You didn't post the code, but you could enclose it in:

If IsNull(Me.MyControl) Or Me.MyControl = "" (or Me.MyControl = 0 if it is a number) Then

'do dLookUp function

End If

You can put this on the On Current event, and the Before Update event, or where ever the code appears. Can you post it if you need more help?

below code is in the MTOW control source which appears only in the form in the form

=DLookUp("MTOW","tblREGMTOW","REGISTRATION = '" & [REGISTRATION] & "'")

Thank you for your help it looks like that have to create a code for that.

brgds
Apostolis
 
Old January 29th, 2009, 04:31 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

So this is not a bound control? If it is bound, do this on the Before Insert and the Before Update events:

Code:
 
If IsNull(Me.MTOW) Or Me.MTOW = "" Then
 
   Me.MTOW=DLookUp("MTOW","tblREGMTOW","REGISTRATION = '" & [REGISTRATION] & "'")
 
End If
Then Lock the control to make it uneditable by the user.

This way the value will be calculated when the record is created, and recalculated if the record is changed AND the control is empty for some reason (for old records, mostly.)

Did that help?
__________________
mmcdonal

Look it up at: http://wrox.books24x7.com
The Following User Says Thank You to mmcdonal For This Useful Post:
otpkma (January 29th, 2009)
 
Old January 29th, 2009, 05:19 PM
Registered User
 
Join Date: Jan 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default stiill not worked

Code:
If IsNull(Me.DLookUpMTOW) Or Me.DLookUpMTOW = 0 Then Me.DLookUpMTOW=DLookUp("MTOW","tblREGMTOW","REGISTRATION = '" & [REGISTRATION] & "'") End If 


Used above in "Before Update" event, as the control is not bound to any table field, it looks that, keeps seeking the value from the DLookUp function in the "Control Source." removed the function from Control Source and than becomes blanc and Unbound, which is expected.
By the way the correct name of the control in the form is "DLookUpMTOW". and the format is Standard Number (FYI the value is the MaxTakeOffWeight of an Aircraft)

Thanks any way need reading and learning as not very experienced in Access, besides that have created this small db on my own to help and manage their day-to-day work in the office.

Thx once again for your help,
Apostolis





Similar Threads
Thread Thread Starter Forum Replies Last Post
Trigger in Access 2003 CarlosV Access 7 April 23rd, 2007 09:50 AM
Access 2003 Treview simmyboy Access 5 July 18th, 2006 02:51 PM
Upgrading from Access 2002 to Access 2003 lryckman Access 1 July 16th, 2006 01:46 AM
Access 2003 n2suns Access 4 May 17th, 2005 03:37 PM
Access 2003 Report bjackman Access 1 July 5th, 2004 05:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.