Moved Form Data to Tab Control

S

scott04

Hi All,

I recently moved all of my form fields to a tabbed control. The reason i
did this was to utilize a subform. My main problem now is that none of my
code is working on the form now. Can some explain why none of the old code
works now and how i can go about getting it to work. Thanks
 
K

kc-mass

You've likely made your form into a subform. Let's say your tab control is
housed on frmTab, your old form was frmMyForm. Your old code likely
referenced a control on your old form as Forms!frmMyform!MyControl. To
reference that control now you have to use Forms!frmTab!frmMyform!MyControl.

Regards

Kevin
 
L

Linq Adams via AccessMonster.com

If the controls in question were simply moved from the form's Detail Section
directly to a page of the tabbed control, you need to "reconnect" the
controls and their event codes.

Courtesy of ADezii at Bytes.com, this code will "reconnect" controls to some
selected Events (OnClick and AfterUpdate in this example.) It can be modified
for other Events, and has the advantage of updating a large number of
controls without doing them one by one.

Private Sub Form_Load()
Dim ctl As Control

For Each ctl In Me.Controls
If (TypeOf ctl Is TextBox) Or (TypeOf ctl Is ComboBox) Then
If ctl.OnClick = "" Then
ctl.OnClick = "[Event Procedure]"
End If
End If
Next

For Each ctl In Me.Controls
If (TypeOf ctl Is TextBox) Or (TypeOf ctl Is ComboBox) Then
If ctl.AfterUpdate = "" Then
ctl.AfterUpdate = "[Event Procedure]"
End If
End If
Next
End Sub

Alternatively, in Design View, you can select a control, go into Properties -
Events and click on the event in question, to take you to the code window, as
if you were setting it up for the first time. Once in the code window, simply
return to Design View. The control is now "connected" to its code and the
hotkey will work. The disadvantage to this is that it's time consuming if it
involves a lot of controls.
 
S

scott04

Thank you for that information...i simply strarted from scratch with the
form...created the tabs and then migrated my code...now everything seems to
work...thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top