Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 15th, 2007, 04:27 PM
jik jik is offline
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dlookup problems

Hi to those that care to view this, I'm new here, but I'll try and discribe the task and problem as best I can:

In access I created a form to reference both site workers and the site offices themselves. The form itself ties into the site table (which does not include the staff). I have create a combo box that looks up the staff memeber's names in the Staff table. What I'm trying to do is then use DLookup to refence the site (which is in the staff table) with the staff member selected and put it into a field (which then advances the form to the record for that office - this part works fine, just can't get the DLookup to work)

here is the code I am using:

Me.Combo23.Value = DLookup("[site]", "[FieldStaff DataSheet]", "[staff] = " & Me![Combo27])

break down:

Combo23 is on the form, this is where you select which site office. After selecting a site here, the form moves to that record. This works fine.
FieldStaff DataSheet is the table containing the staff member's information, including what site that are working at.
site is the field in the table that contains the site names
staff is the field in the table that contains the staff member names.
Combo27 This is the selected staff name. It is looked up in the FieldStaff DataSheet table.

when I run the code I get 1 of 2 errors. The first may cause to be a big problem : Run-time error '3075' Syntax error (comma) in query expression... This seems to be because I have the names as strings "Lastname, Firstname".
I would have just changed the names, but I had a few test names in there without commas. With those I get the error : Run-time error '2001' You canceled the previous operation.

I must admit that I am rather new to VB scripting, though I do program in other languages. I have found it rather difficult to look up any information using the Help built in, so I feel kind of stuck here...


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with DLookup Devilboy13 Access VBA 4 August 30th, 2006 02:48 PM
Help - Dlookup function kk_sg Access VBA 3 August 23rd, 2006 11:30 AM
DLookup Urgent ahying Access VBA 3 August 18th, 2006 11:29 PM
DLookup Teqlump Access VBA 1 August 9th, 2006 11:48 PM
Dlookup with If ..Then ..Else and Chkboxes ecampos Access 16 August 18th, 2005 08:08 AM



All times are GMT -4. The time now is 02:42 PM.


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