Senin, 18 Januari 2016

Re: [MS_AccessPros] Re: Can't figure out my RS is blank



I have no clue how If will deal with the return from the DLookup.  And why are you defining MyTruckTypes and THE_TRUCK_TYPE as local variables and then not using them?

Did you mean to do:

    If Not IsNull((DLookup("[MyTruckTypes]", "[dbo_TRUCK_TYPE]", "[MyTruckTypes]= '" & Me![THE_TRUCK_TYPE] & "'"))) Then


John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)

On Jan 18, 2016, at 6:06 PM, [MS_Access_Professionals] <> wrote:

Thanks for the responses Duane and Liz!

I ditched the idea of trying to pull a record set from a table to compare to a value on the form!

So I am going back to using DLOOKUP to compare a field on the form with a value in another table and if they match, then... throw a message and set a certain Reason Code.

For Duane, I tried the debug.print, seems like I am not getting the results in the DLOOKUP from the table.  And the Me![THE_TRUCK_TYPE] is getting the right data from the field on the form.

Here is my revised code:

Private Sub UNIT_COMBO_ID_AfterUpdate()
Dim MyTruckTypes As String
    If Me.UNIT_COMBO_ID > 0 Then
        Me.THE_TRUCK_TYPE = [UNIT_COMBO_ID].[Column](5)
    End If
    If (DLookup("[MyTruckTypes]", "[dbo_TRUCK_TYPE]", "[MyTruckTypes]= '" & Me![THE_TRUCK_TYPE] & "'")) Then
        MsgBox ("FIXED MASTER, Reason Code set to 'Work Order Variance'")
        Me.REASON_CODE = "Work Order Variance"
    End If
End Sub

Structure of  dbo_TRUCK_TYPE table:
ID = AutoNumber
MyTruckTypes = Text

Thanks again, Rohn


Posted by: John Viescas <>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (6)



Tidak ada komentar:

Posting Komentar