[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 442
  • Last Modified:

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
0
Delirious
Asked:
Delirious
  • 6
  • 4
  • 3
  • +1
2 Solutions
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 6
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now