Results 1 to 4 of 4
  1. #1
    FinChase is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2011
    Posts
    20

    Populate textbox with result of stored query object


    Hi,
    I am building a database where the user is required to enter data into several textboxes and choose some options from combo boxes. This user input is this then utilized in several relativelycomplex queries which also pulls data from a table. I have saved these as database objects. By the time I'm finished with all the queries there will be a minimum of 14 different queries that could be run, depending on the option the user selected.


    Currently, I have a command button on the form that executes the following code:

    Code:
    Private Sub cmdGenText_Click()
        
        If IsNull(Me.txtErrorType) Then
        MsgBox "The Error Description field cannot be left blank"
        Cancel = True
        Me.cboErrorType.SetFocus
    Else
       
       Dim strError As String
       strError = Me.txtErrorType.Value
       
       Select Case strError
            Case "Dup"
                DoCmd.OpenQuery "qryAssembly_Dup", acNormal, acReadOnly
            Case "DupMulti"
                DoCmd.OpenQuery "qryAssembly_DupMulti", acNormal, acReadOnly
            Case "DupPart"
                DoCmd.OpenQuery "qryAssembly_DupPart", acNormal, acReadOnly
    End Select
    
       
    End If
        
    End Sub
    The query runs fine and opens in a query window. However, I want one field of the query to populate an unbound text box on the form instead. So when I click the command button instead of opening the query in a separate window I want a field called Error Text to populate a textbox called txtRxLetter. I'm sure I'm making this harder than I need to, so any help will be appreciated.

    I am using Access 2010.

    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Does query retrieve a single record?

    Why so many queries? Are they essentially the same except for filter criteria?

    Is the form in Single view?

    Query cannot populate textbox. Data can be pulled from table or query.

    Options:

    1. DLookup expression in textbox or in VBA

    2. VBA opens a recordset and grabs value from recordset field
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    FinChase is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Nov 2011
    Posts
    20
    Quote Originally Posted by June7 View Post
    Does query retrieve a single record?

    Why so many queries? Are they essentially the same except for filter criteria?

    Is the form in Single view?

    Query cannot populate textbox. Data can be pulled from table or query.

    Options:

    1. DLookup expression in textbox or in VBA

    2. VBA opens a recordset and grabs value from recordset field
    Thanks for your response.

    Each query will retrieve a single record. They are not the same query; each one is using a number of different variables and fields from a data table which have to be concatenated together in a field called Error Text. The form opens in Single View.

    I am not very familiar with DLookups. Can you point me to a resource for this?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Access Help has info on domain aggregate functions (DLookup, DAvg, DSum, etc). Also, lots on web.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 6
    Last Post: 01-10-2014, 10:04 PM
  2. Replies: 2
    Last Post: 11-27-2013, 05:24 PM
  3. Enter query result in a form textbox
    By Damo10 in forum Forms
    Replies: 2
    Last Post: 06-30-2013, 06:43 PM
  4. open a pdf stored as an ole object
    By khumbo in forum Access
    Replies: 5
    Last Post: 03-16-2013, 12:35 PM
  5. Replies: 12
    Last Post: 06-25-2012, 01:42 PM

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