Wrox Programmer Forums
|
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 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 February 15th, 2007, 04:27 PM
jik jik is offline
Registered User
 
Join Date: Feb 2007
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...







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





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