473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Dlookup issues (fairly new to VB) = Access 2007

Hi, i am trying to get a latest salary figure to be shown in a text field on a parent form, sourced from a sub form.

But with the criteria that it is only for that employee number and that a checkbox indicating that it is the lastest salary has been checked. Here is the VB code I have used

Salary = DLookup("[AnnualNetSalary]", "TalbotTestRole", "[Employee Number]" = Forms!TalbotTestFormPersonalRecords!TalbotTestSubf orm![Employee Number] _
& "[LatestSalary]"" = Forms!TalbotTestFormPersonalRecords!TalbotTestSubf orm![LatestSalary] =" & True)


So, for example, I have two records in my database for John Smith and Tim Ball. Through the year 2008/2009 both have had two roles, where the salary has changed (these are subform records.

Although both salaries are recorded in the subform, on the parent form I only want to show the latest salary figure. To do this, I have a 'Latest Salary' checkbox in the sub form next to the salary field.

So, by clicking the checkbox, the main parent form record for John or Tim will show thier latest salaries.

Thats what I am trying to acheive with the Dlookup code.

Cant quite get it. Can anyone help? Its driving me mad!

thanks

marc
Dec 7 '11 #1
2 1526
Killer42
8,435 Expert 8TB
I don't think you've told us in what way it's not-quite-right.

However, my debugging-senses are tingling.

The parameters of Dlookup consist of three string expressions - Field, Domain and Criteria. Your field and domain look ok. But, while I'm uncertain of my details here, I think your current criteria would resolve simply to something like the string "False". This seems unlikely to be what you intended.

You see, each of those "=" signs which is outside of quotes will be interpreted as a comparison. So for example, you're actually taking the string "[Employee Number]" and testing whether it's the same as the value of the [Employee Number] field on the subform. Seems pretty unlikely to match, wouldn't you say?

To test this, pull out the expression and paste it into a Debug.Print statement like this, immediately before the above statement...
Expand|Select|Wrap|Line Numbers
  1. Debug.Print "[Employee Number]" = Forms!TalbotTestFormPersonalRecords!TalbotTestSubform![Employee Number] & "[LatestSalary]"" = Forms!TalbotTestFormPersonalRecords!TalbotTestSubform![LatestSalary] =" & True
Or to boil it down and demonstrate what I mean in simpler form, try:
Expand|Select|Wrap|Line Numbers
  1. Debug.Print "A = B"
  2. Debug.Print "A" = "B"
Here's an attempt at something closer to what I think you meant to write...
Expand|Select|Wrap|Line Numbers
  1. Salary = Dlookup("[AnnualNetSalary]","TalbotTestRole", _
  2. "[Employee Number] = " _
  3. & Forms!TalbotTestFormPersonalRecords!TalbotTestSubform![Employee Number] _
  4. & " And [LatestSalary] = " _
  5. & Forms!TalbotTestFormPersonalRecords!TalbotTestSubform![LatestSalary])
Couldn't quite work out what to do with your True on the end. You'll have to sort out that part. :)
Dec 15 '11 #2
Killer42
8,435 Expert 8TB
P.S. Another very quick and simple debugging technique you might try. Put a breakpoint on your "Salary=" line. When execution pauses there, select the entire Criteria parameter (that's everything from "[Employee Number]" to True) and hit Shift-F9 (quick watch). It should show you the value that the whole expression resolves to.
Dec 15 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

49
by: Allen Browne | last post by:
If you are looking for opinon on what's useful in Access 2007, there's a new article at: http://allenbrowne.com/Access2007.html Covers what's good (useful features), what's mixed (good and bad),...
2
by: dixcyn04 | last post by:
I did search the forums before asking this and found nothing quite like what I am having trouble with. Perhaps my main issue is a lack of knowledge of Access Database interaction, since most app's I...
17
by: Neil | last post by:
A client of mine likes some of the new bells and whistles in Access 2007, and is thinking about converting our A03 format MDB to an A07 format file. However, while some of the users have A07, many...
16
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might...
2
by: ARC | last post by:
Just curious if anyone is having issues with Acc 2007 once the number of objects and complexity increases? I have a fairly large app, with many linked tables, 100's of forms, queries, reports, and...
10
by: Bobby | last post by:
Hi, The organisation I work for is on the verge of buying Microsoft Office 2007 Pro Plus OLP NL. We currently use Office Pro 2003. Our business system is written in Access 2003 with a SQL Server...
1
BlackPanther
by: BlackPanther | last post by:
Has anyone found any issues running Access applications developed in 2003 under Access 2007?
9
by: prakashwadhwani | last post by:
Hi !! I'm about to develop a new project for a client. Should I go about it in Access 2003 or 2007 ? Purchasing it either for me or for my client is not a major consideration here ... what I'd...
1
by: kihsore | last post by:
Hi All, I have a question on compatibility and conversion issues with Access 2007. My question is will a Runtime created on an early versions of Access 2007 (ie;Access 97,2000,2002,2003) run on...
8
by: Jesse Jones | last post by:
I am using Access 2007 and I am a complete ignoramus with this stuff. I have designed a modal login form for my database that is working perfectly. I did this by placing an invisible dlookup...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.