I need to replace a DLookup with an ADO code

Here is my DLookup code.

If Not IsNull(DLookup("[AUFNR]", "[P4S_WRITE_USER_Z_R3_AUFK_TBL]", "[txtCharge_Code] =" & Me.txtCharge_Code) & "") Then
   MsgBox "This is a invalide code.  Please try again.", vbOKOnly
   End
End If

How would I replace this with ADO code?

Thanks
DeliriousAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tbsgadiCommented:

You can still use that same code with ADO

Gary
0
tbsgadiCommented:
Or are you talking about something else?
0
DeliriousAuthor Commented:
Maybe...

If I needed this same functionality without using DLookup.  What would the code look like.

ADODB.Connection
ADODB.recordset
Dim.....
Dim....

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Jonathan KellyCommented:
Gary I think Delirious wants to open an ADO recordset - correct ?
0
Jonathan KellyCommented:
Delirious - you just got in before me!
0
tbsgadiCommented:
R U 2 related?
0
Jonathan KellyCommented:
would be something like


dim r as new adodb.recordset
dim sql as string
sql = select AUFNR from P4S_WRITE_USER_Z_R3_AUFK_TBL where txtCharge_Code = '" & Me.txtCharge_Code "'"

r.open (sql,currentproject.connection)
r.movefirst
if isnull(r(0)) then
 MsgBox "This is a invalide code.  Please try again.", vbOKOnly
end if

my ado may not be 100% - do you get the idea ?


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jonathan KellyCommented:
<R U 2 related? >  WHY?
0
flavoCommented:
Hi Datrias,
> if isnull(r(0)) then
>  MsgBox "This is a invalide code.  Please try again.", vbOKOnly
> end if
That should be more like:

if rs.eof and rs.bof
 MsgBox "This is a invalide code.  Please try again.", vbOKOnly
end if
Dave :-)
0
Jonathan KellyCommented:
oh yeah - of course Dave - good spot !

0
DeliriousAuthor Commented:
Ok I'm getting there.  I'm working on the sql statement...
0
DeliriousAuthor Commented:
Ok great!  Thanks for the help.  I'll split the points.
0
Jonathan KellyCommented:
fair enough
0
tbsgadiCommented:
Similar names thats all!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.