Microsoft
Software
Hardware
Network
Question : Refresh subform on different tab control
Greetings, Experts...can somebody please help me resolve this? I have a form with 23 tabs, each with a subform linked to its own SQL table. Let's just deal with two for now (subfrm_00_MAIN and subfrm_01_TopDogHouse). Using the following code, I'm trying to refresh the Record_Number of the subform on the second tab, and see it when I click on that tab. This works great if I close the form and reopen, but I get Run-time error '3021': no current record when clicking the 2nd tab. I've tried for a day to resolve this, but can't seem to dial it in. Here's the code:
Private Sub cmdNew_Click()
On Error GoTo Err_cmdNew_Click
Dim strSQL As String
DoCmd.GoToRecord , , acNewRec
DoCmd.SetWarnings False
Me.Record_Number.Value = Format(Now(), "mmddhhnnss")
strSQL = "INSERT INTO dbo_T_01TopDogHouse (Record_Number) VALUES ('" & Me.Record_Number.Value & "');"
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Me.Record_Date.SetFocus
Exit_cmdNew_Click:
Exit Sub
Err_cmdNew_Click:
MsgBox Err.Description
Resume Exit_cmdNew_Click
End Sub
--------------------------
----------
----------
Private Sub TabCtl0_Change()
Select Case Me.TabCtl0.Value
Case 0
Me.subfrm_00_MAIN.Form.Rec
ordsetClon
e.FindFirs
t "Record_Number =" & Me.Record_Number
Me.subfrm_00_MAIN.Form.Rec
ordset.Boo
kmark = Me.subfrm_00_MAIN.Form.Rec
ordsetClon
e.Bookmark
Case 1
Me.subfrm_01_TopDogHouse.F
orm.Record
setClone.F
indFirst "Record_Number =" & Me.Record_Number
Me.subfrm_01_TopDogHouse.F
orm.Record
setClone.B
ookmark = Me.subfrm_01_TopDogHouse.F
orm.Record
setClone.B
ookmark
End Select
End Sub
Answer : Refresh subform on different tab control
one way around this without any code is to put a hidden textbox on your main form that holds the current record_number and then use the control as the Master Linking field for all of your subforms, assuming they are all related to the same key. If you have many relationships then you could use m,ultiple hidden textboxes to let Access take care of sync'ng for you.
Steve
Random Solutions
VB.NET Solution
Allow Access to Website Only from Certain IP Addresses
How to write an Excel if statement that would accomplish figuring the percentage of a dollar amount based on the scale below:
VB FORMULA - Loop
Have full control in Sharepoint but cannot view groiup
There is insufficient system memory in resource pool 'internal' to run this query. WE upgraded from a 32 bit, 4 GB, Windows 2003 server, SQL server 2005 machine to a 64 bit, 2 processor quad core, 8
Printer goes offline during print job
.NET CF Performance counters are missing
"Data type mismatch in criteria expression." when comparing dates
sql server 2005 datetime min