Results 1 to 4 of 4
  1. #1
    epardo87 is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Dec 2016
    Posts
    102

    problem communicating textbox with query

    Hello there,

    I have a very strange problem:

    I have three forms and a query:
    • [frmMain] has [lstDesig].
      • When "btnOK" is clicked [frmUserData] opens up

    • [frmUserData] has [txtOperator]
      • when form is loaded [txtOperator] shows the selection made in [frmMain]![lstDesign] originally with the following code written in the control source field using the expression builder [Forms]![frmMain]![lstDesig] & ""



    • [Qry-Designations] has columns [Station] and [Assigned].
      • The [Assigned] column has the following formula in the criteria field written with the expression builder so that query is filtered [forms]![frmUserData]![txtOperator]

    • [frmUserData] has also [lstStation] which shows the data in [Station] of [Qry-Designations]. This is the code in the Row Source field SELECT [Qry-Designations].Station FROM [Qry-Designations];


    Everything works just fine so far, but I added a new form [frmSearch] which has [cboEmployee], I have been all day trying to alternate the information written in [frmMain]![txtOperator] so that if [frmSearch].IsLoaded then pulls data from [frmSearch]![cboEmployee] Else [frmMain]![lstDesig] and I have the code working well which is the following:
    Code:
    Private Sub Form_Load()
    If CurrentProject.AllForms("frmSearch").IsLoaded Then
    Me.txtOperator = Forms!frmSearch.cboEmployee
    Else
    Me.txtOperator = Forms!frmMain.lstDesig
    End If
    The rare issue here is that, when I click "btnOK" in [frmMain], the form [frmUserData] is correctly open and [txtOperator] is correctly filled with the selection at [lstDesig] but [lstStation] doesn't show the data from the query, the thing is that I changed the form to design view to verify formulas and without changing anything I changed it back to form view and then the data appeared in the listbox! I repeated this a few times, I even closed the file and reopened it and it does that every time. I erased the VBA code of [txtOperator] and wrote again the code it had in the control source field and then it works normal, then I tested the formula Me.txtOperator = Forms!frmMain.lstDesig by itself and it does it again, the same, not showing at first but then showing it after switching back from design view... I find this very odd and can't even imagine what could be happening, I also tried refreshing the form without going into design view but had no success...I'd really appreciate any feedback here
    thanks

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I think this might be hard to give a good answer without seeing the dB.


    not showing at first but then showing it after switching back from design view...
    When this happens , try pressing the "F9" key (Recalc).
    Pressing the F9 key when a form has the focus recalculate the values of controls that depend on other fields for which the contents may have changed.


    If this works, you might be able to use an event to use the reclac method in VBA (Me.Recalc).

  3. #3
    NTC is offline VIP
    Windows 10 Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    I don't fully understand your post. I would advise you move your code from the On Load event to instead be in the On Current event.

    What I don't understand about your post is that your code sample deals only with populating Me.txtOperator, but your description involves a problem with [lstStation] - so that's confusing

  4. #4
    epardo87 is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Dec 2016
    Posts
    102
    Quote Originally Posted by ssanfu View Post
    I think this might be hard to give a good answer without seeing the dB.



    When this happens , try pressing the "F9" key (Recalc).
    Pressing the F9 key when a form has the focus recalculate the values of controls that depend on other fields for which the contents may have changed.


    If this works, you might be able to use an event to use the reclac method in VBA (Me.Recalc).
    This worked! I pressed F9 and everything appeared again, I added the Me.Recalc and now it works beautiful!

    thanks a lot!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Communicating data between tables.
    By jasdem in forum Database Design
    Replies: 6
    Last Post: 02-06-2014, 03:18 PM
  2. Replies: 2
    Last Post: 04-23-2013, 12:44 AM
  3. VB Loading DLL and Communicating with Server
    By Baldeagle in forum Programming
    Replies: 6
    Last Post: 01-07-2013, 02:41 PM
  4. Communicating With SQL Server
    By steve2507 in forum Access
    Replies: 6
    Last Post: 02-13-2012, 03:28 PM
  5. Replies: 2
    Last Post: 09-26-2009, 07:19 AM

Tags for this Thread

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