Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 636
- Office Version
- 365
- 2010
- Platform
- Windows
USERFORM CONTROLS:
TextBoxes:
txtEmpNum
txtFirName
txtLstName
Buttons:
btnEnter
I'm trying to use Excel's userform to add entries into Access. I want to enter the values entered into the textboxes into Access. Thanks.
TextBoxes:
txtEmpNum
txtFirName
txtLstName
Buttons:
btnEnter
I'm trying to use Excel's userform to add entries into Access. I want to enter the values entered into the textboxes into Access. Thanks.
VBA Code:
Sub ConnectDB_Insert()
'Path
Dim strPath As String
'Provider
Dim strProv As String
'Connection String
Dim strConn As String
'Connection
Dim Conn As New Connection
'RecordSet
Dim rsQry As New Recordset
'SQL Query
Dim strQry As String
strPath = "C:\Users\i0380332\OneDrive - Sanofi\Documents\Store_Room.accdb"
strProv = "Microsoft.ACE.OLEDB.12.0;"
strConn = "Provider=" & strProv & "Data Source=" & strPath
'Connection Open
Conn.Open strConn
strQry = "INSERT INTO Personnel VALUES(frmPersonnelEntry.txtEmpNum.text,frmPersonnelEntry.txtFirName.text,frmPersonnelEntry.txtLstName.text,frmPersonnelEntry.txtEmail.text)"
Conn.Execute strQry [B]Error occurs here but it has to do with the above line[/B]
End Sub