Access Projects combo problem

  • if your ever not sure if an event is firing/running code, stick a debug.print in the code there and keep an eye on the immediate window in access - or even better, set a couple of break points and see if its getting to your code, and if it is what its doing.

     

    martin

  • Thanks, Martin

    Good advice.

    Paul

  • "I havn't used Access for about 3 years, but one of the things it used to do, is download all the data of a linked table to a temp file in your local profile.  It is because of this reason that we still discourage the use of Access in our company."

    This statement doesn't make sense.  100% of database development tools, from Access to Oracle to Excel, to VB .NET - they all make it trivial to download entire tables. 

    On the other hand, I could understand why a company would want to prevent random data snooping and downloads, and only permit compiled Access MDEs and ADPs, and not allow the development environment on users' computers. 

    The fact is that Access is the best database client development tool available today. Period.  I just wish .NET and the rest would catch up to Access and give us some real development options. 

  • "However, it works excellently from the GotFocus."

    I don't understand why you would want to send a query to SQL Server every time the user moves to the combo box.  Wouldn't it be better to send the query only the first time that the combo needs to be updated?  I don't know what your actual needs are, but it seems to me that you are better off putting the code in the Form_Open event, where it runs just once.

     

    HTH,

    Rich

  • Thanks Rich

    I have two combos on a small form which allows students to be chosen by either FirstName-LastName or LastName-FirstName.  A double-click on the unique ID then adds the student to a form lying below.  The small form is then closed.

    Most users will use the LasName-FirstName combo - and enter the first letters of the desired lastname.  Using the GotFocus - I guessed - would save resources by giving only one combo a rowsource.

    I will ensure, however, that any form which remains open (and has a combo/s) will have the code entered OnOpen.

    Would several clicks on a combo with Rowsource code in Got Focus open several sets of the same data?  I can't quite get my head around this.

    Thanks again

    Paul

  • "Using the GotFocus - I guessed - would save resources by giving only one combo a rowsource."

    Actually, Access combo boxes queries do not get sent to SQL Server until the combo is opened for the first time.

    (You can prove this in the SQL profiler) (Also, Access apparently asks SQL Server to create  prepared statements for each combo query as the form is loaded.) 

    Therefore, adding a recordsource to both combos will not waste any resources.  If combo2 is never used, the query never gets sent to the server!  Further, every time you assign the recordsource in code (even if it is the exact same recordsource), the combo is not immediately requeried, but is requeried when the list is next dropped down.  This is a waste of resources, especially for a long list of names.

    IIRC, the Enter event is fired the very first time a user enters a control on a form.  You should consider using this event instead of GotFocus for your needs.

    IIRC, GotFocus is fired every time the user enters your control (Ctrl1)  from another control (Ctrl2) on the same form (Form1.)  If Ctrl1 is already active (has the focus) then more clicks to not fire GotFocus again. 

    Also...If the user clicks on a control on Form1 after using another form (Form2), then GotFocus is fired only if Ctrl1 was was not the active control (i.e. has the focus) on Form1.  If Ctrl1 was already the active control for Form1, GotFocus will not fire.

    Yep, it's confusing. 

    HTH,

    Rich

  • Thanks, Rich

    I admire your in-depth knowledge. 

    I'm going to make the change you suggest - as I now understand why I am doing it.

    Excellent help....

    Many thanks again

    Paul

  • Glad to help, Paul.

    You ask very good questions that are not really addressed well in the Help files.  So, keep 'em comin', and I'll try to help if I can (and if I can find time!).

    Rich

     

  • Thanks, Rich

    I certainly will.  It's great to get a leg-up when you need one.

    Best wishes

    Paul

Viewing 9 posts - 16 through 23 (of 23 total)

You must be logged in to reply to this topic. Login to reply