Results 1 to 11 of 11
  1. #1
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    'Can't find form' (2000/03 (SP2))

    I'm trying to reference a text box on a sub-form (that's open) but Access gives me an error message

    Microsoft Office Access can't find the form 'ffrmFindDNFdesc' referred to in a macro expression or Visual Basic code'

    It's tripping up here;
    strDesc = [Forms]![frmFindDNFdesc]![txtDESC1]

    Ideas please

  2. #2
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Can't find form' (2000/03 (SP2))

    Where are you trying to reference it from?
    Check your spelling and if that is correct maybe the following will help Access Web
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: 'Can't find form' (2000/03 (SP2))

    The problem is that it is a subform. Subforms are not part of the forms collection.

    You have to refer to them via the main form.

    strDesc = [Forms]![frmMain]![frmFindDNFdesc]![txtDESC1]

    where frmMain is the name of the main form

    and frmFindDNFdesc is the name of the subform control on the Main form.

    NB The name of the subform control may not be the name of the actual subform within it (but is usually is)
    Regards
    John



  4. #4
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Can't find form' (2000/03 (SP2))

    Hmmm, well I've tried;

    strDesc = [Forms]![FrmDNFnoDesc]![frmFindDNFdesc]![txtDESC1]
    (where FrmFindDNFdesc is the main form)

    I also tried;

    me.FrmFindDNFdesc.frmFindDNFdesc.txtDESC1

    But I still get an error

    MS Access cannot find the field frmFindDNFdesc...

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 'Can't find form' (2000/03 (SP2))

    The syntax is

    Forms!MainFormName!SubformName!ControlName

    where SubformName must be the name of the subform as a control on the main form. This is not necessarily the same as the name of the subform in the database window. Open the main form in design view and click once on the subform to select it. You'll see the control name of the subform in the Object dropdown on the Formatting toolbar, in the title bar of the Properties window and of course in the Name property.

    You write "where FrmFindDNFdesc is the main form" - surely this is a mistake?

  6. #6
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Can't find form' (2000/03 (SP2))

    Yes that was a mistake.

    I've got it now though I'd been; using the actual form name, not the form control name.

    As an aside, I'm using this to populate a control on the main form & it works, but only after exiting the record & then returning, can the change be seen.
    I'd use requery, but then that removes the record. Is there a way of getting the data insertion to show on the button click?

    Here's what I've got so far;
    <span style="background-color: #FFFF00; color: #000000; font-weight: bold">
    Dim strDesc As String

    strDesc = [Forms]![FrmDNFnoDesc]![CR2]![txtDESC1]
    Me.DESC.VALUE = strDesc
    </span hi>

  7. #7
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: 'Can't find form' (2000/03 (SP2))

    Is DESC the name of a control on the form, or the name of a field in the table behind the form, or both?

    I both I suggest you rename the control txtDesc then change your code to Me.txtDesc = strDesc
    so you are explicitly setting a value in a form, rather than a value in the table.

    Of course when you move on, the value from the form will get saved to the table.
    Regards
    John



  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 'Can't find form' (2000/03 (SP2))

    Should the user be able to edit DESC? And should DESC be stored? If the answer to both is no, you can set the Control Source of DESC to

    =[Forms]![FrmDNFnoDesc]![CR2]![txtDESC1]

    It should then be updates automatically.

  9. #9
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Can't find form' (2000/03 (SP2))

    Thanks gents, it now all works as I hoped. <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

  10. #10
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Can't find form' (2000/03 (SP2))

    Just an observation/warning - DESC is a reserved word in SQL (Descending sort order) This could come back to bite you later. If you get the chance to change the name it might be worth doing (not to Description though!).
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  11. #11
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 'Can't find form' (2000/03 (SP2))

    Good point, Steve. I'll be changing that then [img]/forums/images/smilies/smile.gif[/img]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •