Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NotInList Selects Different Page on Tab Control

Status
Not open for further replies.

wvandenberg

Technical User
Oct 24, 2002
125
CA
Hello Everyone,

I am having trouble with code for a NotInList event. Here are the details of my form. I have a main form (frmMain) with a tab control (tabMain). On Page1 of tabMain, I have a subform. In the subform I have a bound combo box (cboClient). I am trying to capture the NewData value from cboClient and then pass it to a textbox on Page2 of tabMain so the user can add the rest ot the client details. The code I have so far gives error 2115 'The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing the database from saving the data in the field'. However, there is no BeforeUpdate or ValidationRule set for this field.

Here is part of the code I am using and it's the last line that throws the error.

Code:
Private Sub fkClientID_NotInList(NewData As String, Response As Integer)
Dim strName As String, strWhere As String
Dim intI As Integer
    
    ' User typed in a name that's not in the list
    strName = NewData
    ' Verify that they want to add the new Contact
    If vbYes = MsgBox("Client '" & NewData & "' is not defined. " & _
        "Do you want to add this Client?", vbYesNo + vbQuestion + vbDefaultButton2, _
            gstrAppTitle) Then
        Me.Parent.tabMain.Pages("pgeClients").SetFocus

Can anyone provide any suggestions on how to do this?

Thanks In Advance
Wendy
 
OK, I re-jigged my code and am still getting the same error. Here is my new code

Code:
Private Sub cboClient_NotInList(NewData As String, Response As Integer)
    Dim rstClone As DAO.Recordset

    Response = AddToList(Me, "tblClients", "Client")
    If Response = acDataErrContinue Then
        Me.cboClient.Undo
    Else
        [highlight]Me.Parent.tabMain.Pages("pgeClients").SetFocus[/highlight]
        ' Find the record that matches NewData.
        Set rstClone = Me.RecordsetClone
        rstClone.FindFirst "[pkClientID] = " & NewData
        Me.Bookmark = rstClone.Bookmark
    End If
End Sub

The error is occurring on the highlighted line.

I thought about moving everything after the Else to the AfterUpdate event for the combo but I only want it to fire if new data is added and I don't know how to do that.

Wendy
 
Have you tried just adding a command button on the subform with the code:
Code:
Me.Parent.tabMain.Pages("pgeClients").SetFocus
If that works (or not) it will tell you something. Report back with your results.


Duane
Hook'D on Access
MS Access MVP
 
Yes, the command button with this code works to select the page.
 
How are ya wvandenberg . . .

Could you post your [blue]AddToList[/blue] function? Alot depends on what your doing here. Particularly in setting the [blue]combobox[/blue] response arguement!

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top