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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not able to go to a control in Subform 1

Status
Not open for further replies.

waldo7474

Technical User
Dec 30, 2002
38
US
Hi all!

I am trying to look up a value, if it is there the database will open that record. I am then trying to add some fields to that record based on a subform. I would like the user to go straight from the "lookup" box directly to where they should enter info into the subform. The only problem is Access keeps telling me that there is no such field on the current form. This is my code. I am pretty new to vba, so bear with me.

Code:
Private Sub PartNumberLookup_AfterUpdate()
    
    Dim rs As DAO.Recordset
    Set rs = Me.RecordsetClone
    rs.FindFirst "PartNumber = """ & PartNumberLookup & """"
    
    'If rs.NoMatch is false, then go to record
    'Else If rs.NoMatch is true, then go to new record
    
    If (Not rs.NoMatch) Then
        Me.Recordset.Bookmark = Me.RecordsetClone.Bookmark
        DoCmd.GoToControl "Me!FrmSubRevAdd!RevNumber"
    Else
        DoCmd.GoToRecord , , acNewRec
        strPartNumberLookup = PartNumberLookup
        PartNumber = PartNumberLookup
        
    End If
    
End Sub

The error that comes up is "Run-time Error '2109': There is no field named 'Me!FrmSubRevAdd!RevNumber' in the current record"

I have tried entering as "Forms!FrmDwgData!FrmSubRevAdd!RevNumber" with no luck either. If I try to move focus to a field on the main form it works. Any ideas what I am doing wrong?

Thanks in advance!!
 
I have never found a way to go directly to a subform like you want. What has worked for me is to move the focus to the subform, then on the subform set the focus to the control you want to be active when it gains the focus.
If anybody else has any ideas I'd like to hear them too.
 
I have had problems with this, also. I can get this to work be setting the focus to the subform first, then to the control on the subform.

For example:

Me![FrmSubRevAdd].SetFocus
Me![FrmSubRevAdd]![RevNumber].SetFocus

It should work all in one statement according to the MS Knowledgebase. Oh well . . . . Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
Thank you for all your help. Both of you helped and it now works!! So thank you very much!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top