Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Access VB Script Question

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,28604
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Access VB Script Question
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Access VB Script Question - 12/4/2005 5:33:22 AM   
  larry369

 

Posts: 1
Score: 0
Joined: 12/4/2005
Status: offline
Hi All,

I just joined your Forum as I need help with VB Script for Access.  I'm trying to synchronize a field in two tables and everything that i have tried from examples I have found on the web do not work.  here are the details of my problem:

I have a web site with a database.  The database contains a table of user info with a field containing a user's password.  Members can update their passwords.
I have the master database on my hard drive. I need to keep the password field in this table in sync with the one on the web site.
I have a query on the web site which extracts the passwords and creates a new table of users and their passwords in my database on my hard drive.
What I want to do is parse thru the master table comparing the password field with the password field i downloaded from the web site and if the passwords are different to change my master table.

This is the code that I was working with:

' Define Variables
    Dim dbMyDB As Database
    Dim rs1 As Recordset
    Set rs1 = dbMyDB.OpenRecordSet("tblMembers", dbOpenDynaset)
    Dim rs2 As Recordset
    Set rs2 = dbMyDB.OpenRecordSet("tblPasswords", dbOpenDynaset)

'Get number of records in tblMembers
    Records = rs1.recordcount
 
'Go to first record in tables
    DoCmd.GoToRecord acDataTable, "tblMembers", acFirst
    DoCmd.GoToRecord acDataTable, "tblPasswords", acFirst

'Update passwords
Update_Passwords:
    If tblMembers.username = tblPasswords.username Then
        If tblMembers.password <> tblPasswords.password Then
            tblMembers.password = tblPasswords.password
        End If
    End If
       
    DoCmd.GoToRecord , , acNext
    Records = Records - 1
    If Records > 1 Then GoTo Update_Passwords
    Exit Sub

Access gives me an error on the first line.  Can anyone help me solve this?  Thanks.

Larry
 
 
Post #: 1
 
 RE: Access VB Script Question - 12/4/2005 7:47:25 AM   
  didorno

 

Posts: 361
Score: 0
Joined: 2/12/2005
From:
Status: offline
larry369,

Your Dim statement is not allowed in vbscript.

Examples of Dim's are :

Dim    Names(9)                        ' Declares a one-dimensional  array with 10 elements
Dim    Names()                          ' Declares a dynamic array
Dim    MyVar, MyNum               ' Declares two variables

Good luck,  

_____________________________

Regular Expression ? I (L+o{1,}v{1,3}e\s)+[iI]t!$

(in reply to larry369)
 
 
Post #: 2
 
 RE: Access VB Script Question - 12/5/2005 2:21:45 AM   
  csamuels


Posts: 42
Score: 0
Joined: 9/26/2005
Status: offline
here's two generic functions to open a connection & recordset to access (openconn) and close both the recordset & connection (closeconn).  You'll need to dim the variables and change routefile to point to your db

routefile = "c:\tasks\actagt2.mdb"
sub openconn ' open a connection to access db'
dim tries
set conn = CreateObject("ADODB.Connection") 'prep connection'
set rs = CreateObject("ADODB.Recordset") ' prep recordset'
tries = 0 ' clear tries counter'
do 'try to open connection to the db
   conn.open "DRIVER={Microsoft Access Driver (*.mdb)};" &_
             "DBQ=" & RouteFile & ";DefaultDir=;UID=;PWD=;"
   tries = tries + 1
   if (err.number <> 0) then 'if errored, close this connection
     conn.close
   end if
Loop While (Err.Number<>0) And tries < 10 'if errored, try again. MAX TRIES = 10
end sub
sub closeconn ' close the connection to the db
rs.close
set rs = nothing
conn.close
set conn = nothing
end sub

(in reply to didorno)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Access VB Script Question Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts