Can someone please correct my codes ?

M

Mac

Public Function REFRESH() As Boolean
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strsql As String
Dim SQLSVRSTR As String
Dim SQLDBStr As String
Dim userpassstr As String
SQLSVRSTR = Trim(Eval("OcOMPANY.fcSQLServer"))
SQLDBStr = Trim(Eval("OcOMPANY.fcSQLDB"))
MsgBox SQLSVRSTR
MsgBox SQLDBStr

'MsgBox ThisForm.grdcomponents.colpart.txtfbompart.Value
strcnn = "DRIVER=SQL SERVER; SERVER=" & SQLSVRSTR & ";" & _
"UID=sa;PWD=just4admin;DATABASE=" & SQLDBStr & ";"

Set cn = New ADODB.Connection
' cn.Open strcnn
MPARTNBR = ThisForm.grdcomponents.colpart.txtfbompart.Value
MPARTREV = ThisForm.grdcomponents.colrev.txtfbomrev.Value
strsql = "Select fonhand from inmast WHERE INMAST.FPARTNO = " & MPARTNBR & "
and INMAST.frev=" & MPARTREV
' strsql = "select * from inmast"
Set rs = New ADODB.Recordset
rs.Cursortype = adopenkeyset
rs.Locktype = adlockoptimistic
cn.Open strcnn
rs.Open strsql, cn
If rs.bof Then
Debug.Print "we don't have any, it seems "
Else
Debug.Print "there are " & rs!fonhand & _
" of them on hand. "
End If
rs.close
cn.close
REFRESH = True
End Function
 
B

Brendan Reynolds

As others have indicated, we could do with some more information here -
what's it supposed to do? What happens when you try to compile it? What
happens when you try to run it? What sort of object is 'ThisForm' and where
and how is it declared? Is this the actual code, cut and copied from the VBA
editor? If so, it looks like you may be missing a reference to the ADO
object library, because many of the ADO methods and constants are not
correctly capitalized, as they would be if VBA was able to resolve the
reference.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top