Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389

    Find data in main form

    This code used in combo box to find any data
    DoCmd.SearchForRecord , "", acFirst, "[ID] = " & Str(Nz(Screen.ActiveControl, 0))



    I want to use it in the after update event of the ID text box made in the form , for this what changes do i have to make in it coding. Note that I will use this in a simple "ID" text box that is directly connected to the table's "ID" control source and not in an unbound combo box.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by deepaksharma View Post
    This code used in combo box to find any data
    DoCmd.SearchForRecord , "", acFirst, "[ID] = " & Str(Nz(Screen.ActiveControl, 0))

    I want to use it in the after update event of the ID text box made in the form , for this what changes do i have to make in it coding. Note that I will use this in a simple "ID" text box that is directly connected to the table's "ID" control source and not in an unbound combo box.
    IMHO that's not a good idea. I would stick to using an unbound combo to find a record. I don't see how you can use a bound control as a control to be used for the entry of data that you want to search for.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    You are right, but I have seen many data software programs that start with ID number (Bill number, Invoice number, Roll number, etc.) By entering the id number, as soon as the enter is hit, the data related to it comes on the form and they easily update the change, they do not use any other unbound box to find the record, then how do the programmers make it possible?

  4. #4
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Bob Fitz View Post
    IMHO that's not a good idea. I would stick to using an unbound combo to find a record. I don't see how you can use a bound control as a control to be used for the entry of data that you want to search for.
    For example you see this demo program if I want I can do this coding in my program but my program has a sub form attached so coding of this form is not working in that form

    https://drive.google.com/file/d/1Au9...w?usp=drivesdk

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,995
    Quote Originally Posted by deepaksharma View Post
    You are right, but I have seen many data software programs that start with ID number (Bill number, Invoice number, Roll number, etc.) By entering the id number, as soon as the enter is hit, the data related to it comes on the form and they easily update the change, they do not use any other unbound box to find the record, then how do the programmers make it possible?
    You would have to save the value and replace it, before the record is saved, located. Fraught with potential problems, more work to maintain. Experienced developers would not do it. That should tell the amateurs something?

    You could overlay an unbound control over the bound control and show and hide it all the time perhaps.
    Otherwise copy the code in that dB?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Welshgasman View Post
    You would have to save the value and replace it, before the record is saved, located. Fraught with potential problems, more work to maintain. Experienced developers would not do it. That should tell the amateurs something?

    You could overlay an unbound control over the bound control and show and hide it all the time perhaps.
    Otherwise copy the code in that dB?
    How will this happen "You could overlay an unbound control over the bound control and show and hide it all the time perhaps."

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,445
    Or just right click on the control to use the built in sort and filter functionality

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by deepaksharma View Post
    You are right, but I have seen many data software programs that start with ID number (Bill number, Invoice number, Roll number, etc.) By entering the id number, as soon as the enter is hit, the data related to it comes on the form and they easily update the change, they do not use any other unbound box to find the record, then how do the programmers make it possible?
    I have no idea. As I've already stated, I would not do it. I would use a combo in the forms header section. Tried, tested, works, been done a million times before. I suspect that the code required to achieve your goal is just not worth the headache. I see no benefit in pursuing it.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,995
    You have a control exactly placed over the other control, same size etc.

    I have never had to need to do it, so you might want to google how, or look on Youtube.

    That DB that you linked to has bound fields, yet uses a recordset to update a record?

    Copy that logic then.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by Welshgasman View Post
    ......That DB that you linked to has bound fields, yet uses a recordset to update a record?

    Copy that logic then.
    Perhaps the OP doesn't like doing things the easy way
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  11. #11
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Welshgasman View Post
    You have a control exactly placed over the other control, same size etc.

    I have never had to need to do it, so you might want to google how, or look on Youtube.

    That DB that you linked to has bound fields, yet uses a recordset to update a record?

    Copy that logic then.
    yes this uses a recordset to update a record.

  12. #12
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    [QUOTE=Bob Fitz;516084]I have no idea. As I've already stated, I would not do it. I would use a combo in the forms header section. Tried, tested, works, been done a million times before. I suspect that the code required to achieve your goal is just not worth the headache. I see no benefit in pursuing i

  13. #13
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Bob Fitz View Post
    Perhaps the OP doesn't like doing things the easy way
    If you see my demo program once,

  14. #14
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,995
    Quote Originally Posted by deepaksharma View Post
    If you see my demo program once,
    One of the hardest thing I had to get my head around when I started with Access, was the idea of bound controls.
    I had dabbled with Foxpro in the past and there you would Scatter Memvar to put in form and Gather Memvar to put back to the table.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  15. #15
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Bob Fitz View Post
    Perhaps the OP doesn't like doing things the easy way
    Ok, I would like to apply your method. Please tell me whether I can create this find combo box only on the form header footer or in the form working area also and My second question is whether the combo box can be stopped from showing the list and if yes then how?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Subform data clears after entering data into main form
    By DarkSilence1979 in forum Forms
    Replies: 19
    Last Post: 03-09-2023, 12:40 PM
  2. Replies: 4
    Last Post: 09-08-2016, 06:35 AM
  3. Replies: 1
    Last Post: 04-26-2016, 05:24 PM
  4. Replies: 11
    Last Post: 02-22-2015, 01:25 PM
  5. Replies: 4
    Last Post: 06-10-2013, 08:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums