Moved controls to tabbed page, controls not working (1 Viewer)

RCheesley

Registered User.
Local time
Today, 18:35
Joined
Aug 12, 2008
Messages
243
Hi all,

I (foolishly) took a dislike to the layout I had on a form, and decided to put a tabbed layout in its place. I copy/pasted the controls into the relevant pages, however now none of the VBA is working.

I'm assuming that I need to declare somewhere the information about the page it's now sitting on but where, and what syntax?

Here's an example of the code I have for a command button, which takes the NHS number entered in a text box and opens the relevant patient record:

Code:
Private Sub cmdFindPatient_Click()
On Error GoTo Err_cmdFindPatient_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmPatientDetailsWithTabs"
    
    stLinkCriteria = "[PatientDetailsNHSNumber]=" & Me![TxtNHSNumberForSpecimen]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    [Forms]![frmPatientDetailsWithTabs].TabCtrl1.Pages(0).SetFocus

Exit_cmdFindPatient_Click:
    Exit Sub

Err_cmdFindPatient_Click:
    MsgBox Err.Description
    Resume Exit_cmdFindPatient_Click
    
End Sub

Since moving it onto the tabbed-interface nothing happens when clicking on the button.

Ruth
 

RuralGuy

AWF VIP
Local time
Today, 11:35
Joined
Jul 2, 2005
Messages
13,826
Go to the property sheet for the control and press the "..." button again. It will relink the code. It will need to be done to all of the controls that are not working.
 

RCheesley

Registered User.
Local time
Today, 18:35
Joined
Aug 12, 2008
Messages
243
Ahar, now that's a useful blimmin tip!

Will give it a go, thanks for that :)
 

RCheesley

Registered User.
Local time
Today, 18:35
Joined
Aug 12, 2008
Messages
243
Woohooo, thanks for that, such a simple tip but it's had me stumped all day!
 

missinglinq

AWF VIP
Local time
Today, 13:35
Joined
Jun 20, 2003
Messages
6,423
Courtesy of ADezii at Bytes.com, this code will "reconnect" controls to some selected Events. It can be modified for other Controls and Events, and has the advantage of updating a large number of controls without doing it one by one.

Code:
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
 
Last edited:

RuralGuy

AWF VIP
Local time
Today, 11:35
Joined
Jul 2, 2005
Messages
13,826
Not at my level yet but the mountain tops have some. Color just came and went. That was fast. Love every minute of it. Thanks for asking Linq.
 

Users who are viewing this thread

Top Bottom