Re: VBA SQL



On Jul 31, 10:51 am, "Baz" <b...@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Set rsVendor = db.OpenRecordset(sqlVendor)

If rsVendor.BOF and rsVendor.EOF Then
'Whatever you want to do if there's no record
Else
strVenName = rsVendor!vendor_name
End If

However, you might find this easier than rewriting all your domain aggregate
function calls:

http://www.mvps.org/access/modules/mdl0012.htm

"Starke" <starke1...@xxxxxxxxxxx> wrote in message

news:1185892524.364073.198620@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I have a database that I am converting to a mysql backend so I can
access it across a wan a little better (hopefully).. Im converting my
DLookups to sql statements but I have an issue when they return no
records. See below for the code. Also, what are your thoughts of
converting the access db to a mysql backend with use over a t1 wan?

Thanks,

Dave

Set db = CurrentDb

sqlVendor = "SELECT vendor_name from tblClaims " & _
"Where purchase_order ='" & Me.txtPO & "'"

sqlTransExist = "SELECT id from tblClaims " & _
"Where purchase_order ='" & Me.txtPO & "'" & _
" and manager_id = 2"

Set rsVendor = db.OpenRecordset(sqlVendor)

strVenName = rsVendor!vendor_name

' ----------- my problem is here, when sqlVendor returns no record,
I get a box that pops up ' ---------------and says 'No Current Record'
once I try to assign strVenName the value.. any help '---------------
would be appreciated./.

Set rsTransExist = db.OpenRecordset(sqlTransExist)

If IsNull(rsTransExist) Then
Me.lblTransExist.Caption = "NO"
Else
Me.lblTransExist.Caption = "YES"
End If

Great!!! That worked, I'll take a look at your suggestion as well. I
was trying to test for Null and of course that wasnt working..

.



Relevant Pages

  • Re: VBA SQL
    ... Set rsVendor = db.OpenRecordset ... strVenName = rsVendor!vendor_name ... access it across a wan a little better.. ... converting the access db to a mysql backend with use over a t1 wan? ...
    (comp.databases.ms-access)
  • Re: VBA SQL
    ... access it across a wan a little better.. ... DLookups to sql statements but I have an issue when they return no ... converting the access db to a mysql backend with use over a t1 wan? ... DLookups() as described. ...
    (comp.databases.ms-access)
  • VBA SQL
    ... I have a database that I am converting to a mysql backend so I can ... access it across a wan a little better.. ...
    (comp.databases.ms-access)