Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Recordset in vba + access
Old 03-04-2008, 01:53 PM Recordset in vba + access
Novice Talker

Posts: 5
Trades: 0
Why my code doesnt work properly?
letīs see my example:

Dim USER As String
Dim pswd As String
Dim userfromfrm As String
Dim pswfromfrm As String
Dim stDocName As String
Dim QUERY As String

Option Compare Database
Private Sub botrunmacro_Click()
' On Error GoTo Err_botrunmacro_Click
' TOMNO LOS VALORES DE LOS OBJETOS DEL FORM
userfromfrm = Form_FrmRunMacro.user01.Value
pswfromfrm = Form_FrmRunMacro.psw01.Value

' TENGO QUE RECUPERAR LOS VALORES DE LA TABLA

USER = Form_FrmRunMacro.Usuario.Value
pswd = Form_FrmRunMacro.ClavedeAcceso.Value

ArgSQL = "SELECT Usuario, Clavedeacceso from TBLUSUARIOS where TBLUSUARIOS.Usuario=" & userfromfrm & " & TBLUSUARIOS.ClaveDeAcceso =" & pswfromfrm & ";"

Dim USUS01 As Variant
Dim CLAVE01 As Variant
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset(ArgSQL, adOpenKeyset, adLockOptimistic)

With rst

If (.RecordCount > 0) Then

'MACHEO LOS PERFILES
Select Case Usuario
Case "OPCODE "
stDocName = "MACROOPENOPCODE"
End
Case "OPVTAGRAL"
stDocName = "MACROOPENOPVTAGRAL"
End
Case "USUARIOBASE"
stDocName = "MACROOPENUSUARIOBASE"
End
Case "ADMINISTRADOR"
stDocName = "MACROOPENUSUARIOBASE"
End
Case ""
MsgBox ("Debe ingresar usuartio y clave validos")
End
Case " "
MsgBox ("Debe ingresar usuartio y clave validos")
End

End Select

'EJECUTO LA MACRO PARA ACCEDER AL FORM INDICADO
DoCmd.RunMacro stDocName

rst.MoveNext

Else
MsgBox "Oops! No records!"
End If
End With
rst.Close

Anybody please, help!!!
ludmila is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-04-2008, 03:56 PM Re: Recordset in vba + access
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
knowing what it is doing or not doing would be a help.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-05-2008, 10:21 AM Re: Recordset in vba + access
Novice Talker

Posts: 5
Trades: 0
I will write below the code which i have problems with, error that shows is some parameters are not define.


Dim USER As String
Dim pswd As String
Dim userfromfrm As String
Dim pswfromfrm As String
Dim stDocName As String
Dim ArgSQL As String
Option Compare Database
Private Sub botrunmacro_Click()
' On Error GoTo Err_botrunmacro_Click

' TOMNO LOS VALORES DE LOS OBJETOS DEL FORM
userfromfrm = Form_FrmRunMacro.user01.Value
pswfromfrm = Form_FrmRunMacro.psw01.Value

' TENGO QUE RECUPERAR LOS VALORES DE LA TABLA

USER = Form_FrmRunMacro.Usuario.Value
pswd = Form_FrmRunMacro.ClavedeAcceso.Value


ArgSQL = "SELECT Usuario, Clavedeacceso from TBLUSUARIOS where TBLUSUARIOS.Usuario=" & userfromfrm & " & TBLUSUARIOS.ClaveDeAcceso =" & pswfromfrm & ";"

Dim con As New ADODB.Connection

Dim USUS01 As ADODB.Field

Set con = Application.CurrentProject.Connection
Set rs = CreateObject("ADODB.RecordSet")

rs.Open ArgSQL, con, adOpenForwardOnly, adLockReadOnly, adCmdText

Do Until rs.EOF
USUS01 = rs.Fields("USUARIO").Value
For Each USUS01 In rs.Fields
Select Case USUS01
Case "OPCODE "
stDocName = "MACROOPENOPCODE"
End
Case "OPVTAGRAL"
stDocName = "MACROOPENOPVTAGRAL"
End
Case "USUARIOBASE"
stDocName = "MACROOPENUSUARIOBASE"
End
Case "ADMINISTRADOR"
stDocName = "MACROOPENUSUARIOBASE"
End
Case ""
MsgBox ("Debe ingresar usuartio y clave validos")
End
Case " "
MsgBox ("Debe ingresar usuartio y clave validos")
End

End Select

DoCmd.RunMacro stDocName
Next
rs.MoveNext
Loop
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing

End Sub

'------------
I will apreciate your answer.
ludmila is offline
Reply With Quote
View Public Profile
 
Old 03-06-2008, 04:41 PM Re: Recordset in vba + access
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Debug.Print (ArgSQL)

Then take the results from the output console and paste those into a new query, try to run it, and take action as necessary.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Recordset in vba + access
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.58596 seconds with 12 queries