Results 1 to 11 of 11
  1. #1
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Requery Textbox (97)

    Hi

    I have a main form that lists details of a product along with its associated company, including the company's address (a many to one relationship). When a user comes across a company that does not have an address, they double click on the address textbox field and this opens the company details form. They then add in the company's address and close this form and returns to the main form.

    However, the newly added address does not show in the address textbox field in the main form. I have tried various ways to requery the textbox to display it, but the only one that seems to work is to requery the main form, which has the undesired effect of goes to the first record after requerying.

    Some advice would be much appreciated on how to requery the address textbox.

    Thanks
    WTH

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Requery Textbox (97)

    <pre>Dim position As Long
    position = Me.nameid
    Me.Requery
    Me.Recordset.FindFirst "[NameID] = " & position</pre>

    This assume that you replace NameID with a unique field of your form and the field is numeric.
    If the unique field is a text field, use
    <pre>Dim position As String
    position = Me.nameid
    Me.Requery
    Me.Recordset.FindFirst "[NameID] = '" & position & "'"</pre>

    Francois

  3. #3
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Requery Textbox (97)

    Hi

    Thanks for pointing me in the right direction.

    Regards
    WTH

  4. #4
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Requery Textbox (97)

    How do you make the company details form open when you double click the address text box? This is a technique I can use. Thanks.

  5. #5
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Requery Textbox (97)

    Hi

    DoCmd.OpenForm "frmDebtor Creditor1", , , "[Organ_ID] = " & Me![OrganID], , acHidden
    Forms![frmDebtor Creditor1].Visible = True

    Regards
    WTH

  6. #6
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Requery Textbox (97)

    In response to my previous question, I assume you did it using the On DblClick event of the text box. Sorry for the dumb question!

  7. #7
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Requery Textbox (97)

    Hi

    Yes

    Regards
    WTH <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  8. #8
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Requery Textbox (97)

    Thanks, WTH. Where did you place Francois' code?

  9. #9
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Requery Textbox (97)

    Hi

    The actual code I used is:

    Dim numitem As String
    numitem = Me.[ tnp_ref]
    Me.Requery
    Me.RecordsetClone.FindFirst "[ tnp_ref] = '" & numitem & "'"
    Me.Bookmark = Me.RecordsetClone.Bookmark

    At this stage I'm using a button to allow the user to refresh the record.

    Regards
    WTH

  10. #10
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Requery Textbox (97)

    Francois,

    Where would you put this code?

  11. #11
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Requery Textbox (97)

    Just after the docmd.openform, but you have to open the form as dialog

    <pre>DoCmd.OpenForm "frmDebtor Creditor1", , , "[Organ_ID] = " & Me![OrganID], , acDialog
    Dim position As Long
    position = Me.[tnp_ref]
    Me.Requery
    Me.Recordset.FindFirst "[tnp_ref] = " & position</pre>


    remove this line
    Forms![frmDebtor Creditor1].Visible = True
    Francois

Posting Permissions

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