Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 640
- Office Version
- 365
- 2010
- Platform
- Windows
I'm using the Excel Userform on the front end and Access on the back end. So after the Enter button is pressed, the information on the form is entered into the database but the database won't "Refresh All" at the line with "DoCmd.Requery". However, when I place a break at "Unload Me" and step through the next line "DoCmd.Requery", it then refreshes the database. Any help explaining why VBA does this or how to fix this issue would be very helpful. Thank you.
VBA Code:
Private Sub btnEnter_Click()
Call ConnectDB_Insert
Unload Me
DoCmd.Requery
End Sub
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 reQry As New Recordset
'SQL Query
Dim strQry As String
strPath = "C:\Users\Name\OneDrive\Documents\Personnel.accdb"
strProv = "Microsoft.ACE.OLEDB.12.0;"
strConn = "Provider=" & strProv & "Data Source=" & strPath
'Connection Open
Conn.Open strConn
strQry = "INSERT INTO Personnel ([Employee #], [First Name], [Last Name], [Email]) VALUES('" & frmPersonnelEntry.txtEmpNum.Text & "','" & frmPersonnelEntry.txtFN.Text & "','" & frmPersonnelEntry.txtLN.Text & "','" & frmPersonnelEntry.txtEmail.Text & "')"
Conn.Execute strQry
End Sub