Hi all I have something that I've been working at for 2 days straight and intermittently for 2 weeks now.
None of the solutions online have worked, I think I saw one other person who had my problem but it wasn't the same fix.
Explanation: When setting my single record form's
Details & Considerations:
I have a split database, the back-end is on my network drive and the front-end is in my documents folder on my local drive.
I am trying to update a single record form that has one of my tables
With VBA code I open the
The front end form is fairly complex and has a lot of CBOs and has a subform in a subform, but if the
I don't have a lot of indexes or records in my database.
Code:
I have tried:
The only thing that "works" is setting a timer and checking to see if the form has updated correctly and running Me.Requery every second until it does.
However this isn't ideal and causes the form to flash every time it requeries and I would hope it to be much simpler
Does anyone know why this is happening or how to fix it?
Thank you I greatly appreciate any help given
Below is the backend relationship if that matters
None of the solutions online have worked, I think I saw one other person who had my problem but it wasn't the same fix.
Explanation: When setting my single record form's
.Filter
or .RecordSource
to a new record I immediately made prior, .Requery
does not populate the form with the new data unless one waits 5 or so seconds after the new record was added with Recordset.Add
and Recordset.Update
. If it don't wait requery leaves a blank form if I apply a filter, and doesn't change a thing if I change the RecordSource to a SQL query targeting the new record. Manually refreshing with F5 will bring the record up after waiting.Details & Considerations:
I have a split database, the back-end is on my network drive and the front-end is in my documents folder on my local drive.
I am trying to update a single record form that has one of my tables
Parts
as its RecordSource.With VBA code I open the
Parts
recordset in the backend db, in a new workspace, add the record and commit the transaction.The front end form is fairly complex and has a lot of CBOs and has a subform in a subform, but if the
.Update
is synchronus it should just be slow and still eventually update.I don't have a lot of indexes or records in my database.
Code:
Code:
Private Function CreatePart() As Boolean
Dim objFSO As New FileSystemObject
If objFSO.FolderExists(obj_PartPaths.FullPath) = False Then
If MsgBox("New part number detected. Select OK to create a new part folder structure for " & str_PartNumber, vbOKCancel, "New Part Number") _
= vbOK Then
obj_PartPaths.CreatePartFolder
obj_PartPaths.CreateInternalFolders
Else
CreatePart = False
Exit Function
End If
End If
Dim wsp As DAO.Workspace: Set wsp = CreateWorkspace("CreatePart", "admin", "")
Dim db As Database: Set db = OpenDatabase(BE_DB)
Dim rstParts As Recordset: Set rstParts = db.OpenRecordset("Parts")
Debug.Print "Record count immediately before transaction: "; DCount("*", "Parts")
wsp.BeginTrans
rstParts.AddNew
rstParts!stxPartNumber = str_PartNumber 'Private module level variables
rstParts!stxCustomer = str_CustomerName
rstParts.Update
wsp.CommitTrans
'This prints the same as the debug line above showing the record is added, yet the following requery does nothing to update the form unless a 5 second timer delay is added to the form. It can take longer than 5 seconds
Debug.Print "Record count immediately after transaction: " & DCount("*", "Parts") & vbNewLine & vbNewLine
[Form_Engineer Toolkit].Requery
DoCmd.OpenForm "Engineer Toolkit", , , "stxPartNumber = '" & str_PartNumber & "'"
rstParts.Close
Set rstParts = Nothing
Set db = Nothing
Set wsp = Nothing
CreatePart = True
End Function
I have tried:
- Adding
DoEvents
after.Update
.Refresh
after.Update
.Requery
and.Refresh
after.Update
- Commiting transactions and then
.Requery
.RecordSource
instead of.Filter
- I unsuccessfully tried the
Me.Bookmark = rst.Bookmark
method, as for some reason when I doSet rst = Me.RecordsetClone
it throws an error saying my front-end database is already in use? This happens regardless of whether I have shared or exclusive mode enabled
The only thing that "works" is setting a timer and checking to see if the form has updated correctly and running Me.Requery every second until it does.
However this isn't ideal and causes the form to flash every time it requeries and I would hope it to be much simpler
Does anyone know why this is happening or how to fix it?
Thank you I greatly appreciate any help given
Below is the backend relationship if that matters