The Dlookup seems to work fine on its own. I tested it with a text box that was set to:
Expand|Select|Wrap|Line Numbers
- = DLookup("[Open/Closed]", "[tblName]", "[cboMoveTo1] = " & [Forms]![Master]![cboMoveTo1])
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:
Expand|Select|Wrap|Line Numbers
- 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