Open form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi! I have a main form with 10 tab controls (subform). My problem is when I
ran a code (the code is in the main form) that has a Me.Requery. It would
run the code, requery and show (or open) the form on the first record and on
the default tab (which is TAB01). Is it possible that after requery, it
would show the tab and record where I am at so I dont have to search for the
record and open the tab?

Thanks in advance!
 
benji, put this code around your me.requery.
MyTabCtl is the name or your tabctl
MyRecordID is the id of the record on your main form
tblMyTable is the table the form is based on

If your key is text, this will require slight modification next to last
line:
Me.Recordset.FindFirst "[tblMyTable].[MyRecordID] = " & pop1 &
Placeholder & pop1

Then use the corresponding Dim for Placeholder and rem out the unneeded line
'if your key is numeric,
Dim Placeholder as Long
'if your key is text,
'Dim Placeholder As String
Dim lngTab as Long
Dim pop1 As String
pop1 = chr$(39)
If Me.RecordsetClone.RecordCount = 0 Then
Exit Sub
End If
lngTab = myTabCtl.Value 'save the tab position
Placeholder = [MyRecordID] 'save key
Me.Requery
Me.Recordset.FindFirst "[tblMyTable].[MyRecordID] = " & Placeholder
MyTabCtl.Value = lngTab 'restore tab

HTH, UpRider
 
It worked well!

Thanks for the help!

UpRider said:
benji, put this code around your me.requery.
MyTabCtl is the name or your tabctl
MyRecordID is the id of the record on your main form
tblMyTable is the table the form is based on

If your key is text, this will require slight modification next to last
line:
Me.Recordset.FindFirst "[tblMyTable].[MyRecordID] = " & pop1 &
Placeholder & pop1

Then use the corresponding Dim for Placeholder and rem out the unneeded line
'if your key is numeric,
Dim Placeholder as Long
'if your key is text,
'Dim Placeholder As String
Dim lngTab as Long
Dim pop1 As String
pop1 = chr$(39)
If Me.RecordsetClone.RecordCount = 0 Then
Exit Sub
End If
lngTab = myTabCtl.Value 'save the tab position
Placeholder = [MyRecordID] 'save key
Me.Requery
Me.Recordset.FindFirst "[tblMyTable].[MyRecordID] = " & Placeholder
MyTabCtl.Value = lngTab 'restore tab

HTH, UpRider

benj said:
Hi! I have a main form with 10 tab controls (subform). My problem is when
I
ran a code (the code is in the main form) that has a Me.Requery. It would
run the code, requery and show (or open) the form on the first record and
on
the default tab (which is TAB01). Is it possible that after requery, it
would show the tab and record where I am at so I dont have to search for
the
record and open the tab?

Thanks in advance!
 
Back
Top