PC Review


Reply
Thread Tools Rate Thread

Dlookup issue with Access 2003! PLEASE HELP!!!

 
 
Steve Earley
Guest
Posts: n/a
 
      10th Jan 2010
I'm working in Access 2003. What I am trying to do is on the click event of "Command167", run a Dlookup on the number that was just typed into "cboMoveTo1" and find the value located in the table "tblName" in the "Open/Closed" field.

The Dlookup seems to work fine on its own. I tested it with a text box that was set to:

= DLookup("[Open/Closed]", "[tblName]", "[cboMoveTo1] = " & [Forms]![Master]![cboMoveTo1])

and it would bring back the correct data.

Then what I need it to do is check to see if the Dlookup return equals "Locked" (from the "Open/Closed" field and if it does, display the message box only (without going to that record).

If the Dlookup returns anything other than "Locked", it will go onto the Recorset and bring up the old record for editing.

Here is the code I have that doesn't seem to work:




Private Sub Command167_Click()

Dim varX As Variant
varX = DLookup("[Open/Closed]", "[tblName]", "[cboMoveTo1] = " & [Forms]![Master]![cboMoveTo1])

If varX = "Locked" Then
MsgBox "This reference # is currently being edited by another user. Please choose another Reference #!"
Else


Dim rs As DAO.Recordset

If Not IsNull(Me.cboMoveTo1) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set rs = Me.RecordsetClone
rs.FindFirst "[Reference #] = " & Me.cboMoveTo1
If rs.NoMatch Then
MsgBox "Reference # not found. Please re-enter."
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
End If
End If
Set rs = Nothing
Set varX = Nothing

End Sub



Seems simple enough, but no matter what I do, it won't work!!!! It always goes directly to the old record, whether it's locked or not.
I am brand new at this so I really shouldn't say it looks simple because it's all new, but I'm learning!!!

Any help would be greatly appreciated!!!!

Thanks!



Submitted via EggHeadCafe - Software Developer Portal of Choice
Custom Self-Expanding Multiselect Winforms ListBox
http://www.eggheadcafe.com/tutorials...nding-mul.aspx
 
Reply With Quote
 
 
 
 
Marco Pagliero
Guest
Posts: n/a
 
      10th Jan 2010
On 10 Jan., 03:50, Steve Earley wrote:
> The Dlookup seems to work fine on its own. I tested it with a text box that was set to:
> = DLookup("[Open/Closed]", "[tblName]", "[cboMoveTo1] = " & [Forms]![Master]![cboMoveTo1])
> and it would bring back the correct data.


This is the question. Your IF structure seems allright so if
> If varX = "Locked" Then

doesn't work, something must be wrong with "Locked". Maybe varX has
trailing blanks or it is lowercase.
Next try with

> If trim(ucase(varX)) = "LOCKED" Then


and let us know.

Greetings
Marco
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recreate VLookup in MS Access 2003 Form Using DLookup..... CBender Microsoft Access VBA Modules 4 8th Apr 2010 04:11 AM
Recreate VLookup in MS Access 2003 Form Using DLookup..... CBender Microsoft Access Form Coding 1 6th Apr 2010 07:35 PM
DLookup in Access 2003 =?Utf-8?B?YmxhemVya2xr?= Microsoft Access VBA Modules 2 4th Oct 2007 08:32 AM
Re: DLookUp Access 2003 spencer4 Microsoft Access Queries 0 17th Jul 2004 10:10 PM
Access 2003 DLookup Query Error 3072 Joe Giaquinto Microsoft Access Queries 2 19th Dec 2003 03:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:43 PM.