> Hi Douglas
> Thank you fro trim suggestion but I am still getting same error when in
> debug test ="" StockCode is "010464" as entered Lotnumber is 1234
>
> Am I right in thinking dlookup formula is looking up stockcode entered in
> table detail and seeing if lotnumber matches a lotnumber in a record with
> entered stockcode and if can't find returns null I think this is failing
> at
> finding stockcode in detail table but I donot know why
> Regards
> Tina
>
> "Douglas J. Steele" wrote:
>
>> Try
>>
>> test = DLookup("[StockCode]", "[detail]", "[StockCode] Like '" &
>> Me.LotNumber& "*'")
>>
>> or
>>
>> test = DLookup("[StockCode]", "[detail]", "Trim([StockCode]) = '" &
>> Me.LotNumber& "'")
>>
>>
>>
>> --
>> Doug Steele, Microsoft Access MVP
>>
http://I.Am/DougSteele>> (no e-mails, please!)
>>
>>
>> "tina" <tina[ at ]discussions.microsoft.com> wrote in message
>> news:E164893E-970C-4122-BC8F-E584118DD310[ at ]microsoft.com...
>> > Thank you Bonnie
>> > Although now I am getting a invaid use of null error
>> > the stockcode in detail is an imported table an sql database where the
>> > field
>> > length is 30 but only 6 characters used when entering in form enter
>> > only 6
>> > characters will this cause test to be ""
>> > Tina
>> > "bhicks11 via AccessMonster.com" wrote:
>> >
>> >> See what Doug said above. It should be:
>> >>
>> >> test = DLookup("[StockCode]", "[detail]", "([StockCode] = '" &
>> >> Me.>LotNumber
>> >> & "')")
>> >>
>> >> Mia culpa.
>> >>
>> >> Bonnie
>> >>
http://www.dataplus-svc.com>> >>
>> >> tina wrote:
>> >> >Hi
>> >> >Sorry to be a pain but this still has syntac error
>> >> >
>> >> >Private Sub LotNumber_BeforeUpdatePrivate Sub
>> >> >LotJob_BeforeUpdate(Cancel
>> >> >As
>> >> >Integer)
>> >> >Dim test As String
>> >> >test = DLookup("[StockCode]", "[detail]", "([StockCode] = '" & Me.
>> >> >LotNumber"'))
>> >> >If IsNull(test) Then
>> >> > MsgBox " your lot number is wrong"
>> >> > Me.LotNumber.SetFocus
>> >> >End If
>> >> >End Sub
>> >> >where table name is detail do I need to declare table names etc
>> >> >Thanks
>> >> >Tina
>> >> >
>> >> >> test = DLookup("[StockCode]", "[TheTable]", "([StockCode] = '" &
>> >> >> Me.
>> >> >> LotNumber"'))
>> >> >[quoted text clipped - 13 lines]
>> >> >> >> >Thanks
>> >> >> >> >Tina
>> >>
>> >> --
>> >> Message posted via AccessMonster.com
>> >>
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200811/1>> >>
>> >>
>>
>>
>>