I have been struggling with how to update a table in an external database and I found a really easy way to do it (for me anyway) and I'm wondering if it would be worthy of a FAQ. I've never written one and perhaps it just outright sucks but below is what I have. Please let me know if it's worthy.
Private Sub cmdsubmit_Click()
'This program will insert data in to the name and pass fields in the tbltooling table _
located on the user's P drive. First the user must establish a reference to the _
DAO object model. _
Do this by left clicking Tools-->Left clicking References--> Then find the _
reference that says Microsoft DAO 3.X Object Library--> Select the box and left click OK.
'Note: The "X" after 3. represents a number that may be different for each user.
Dim dbs As Database, strdb As String, strSQL As String
Dim strname As String, strpass As String 'These variables will hold the _
values that will be sent to our database.
strname = Me.tbname.Value 'Person's name
strpass = Me.tbpassword.Value 'Person's password
strdb = "P:\Toolroom\ToolRoom.mdb" 'Insert the path to your Access database
Set dbs = OpenDatabase(strdb)
strSQL = "INSERT INTO tbltooling1 ([pass],[name])" _
& " VALUES('" & strpass & "','" & strname & "');"
dbs.Execute (strSQL)
dbs.Close
End Sub
Just wondering
![[reading] [reading] [reading]](/data/assets/smilies/reading.gif)
Rib
Bartender:Hey aren't you that rope I threw out an hour ago?
Rope:No, I'm afraid knot.
Private Sub cmdsubmit_Click()
'This program will insert data in to the name and pass fields in the tbltooling table _
located on the user's P drive. First the user must establish a reference to the _
DAO object model. _
Do this by left clicking Tools-->Left clicking References--> Then find the _
reference that says Microsoft DAO 3.X Object Library--> Select the box and left click OK.
'Note: The "X" after 3. represents a number that may be different for each user.
Dim dbs As Database, strdb As String, strSQL As String
Dim strname As String, strpass As String 'These variables will hold the _
values that will be sent to our database.
strname = Me.tbname.Value 'Person's name
strpass = Me.tbpassword.Value 'Person's password
strdb = "P:\Toolroom\ToolRoom.mdb" 'Insert the path to your Access database
Set dbs = OpenDatabase(strdb)
strSQL = "INSERT INTO tbltooling1 ([pass],[name])" _
& " VALUES('" & strpass & "','" & strname & "');"
dbs.Execute (strSQL)
dbs.Close
End Sub
Just wondering
![[reading] [reading] [reading]](/data/assets/smilies/reading.gif)
Rib
Bartender:Hey aren't you that rope I threw out an hour ago?
Rope:No, I'm afraid knot.