User Profile

Collapse

Profile Sidebar

Collapse
mbedford
mbedford
Last Activity: Sep 28 '10, 02:13 PM
Joined: May 20 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • mbedford
    started a topic I'm missing something: Dependent queries

    I'm missing something: Dependent queries

    qryKeyEmployeeK ey
    based on control in form:
    Code:
    SELECT UID
    FROM listEmployeeKey
    WHERE KeyID=Forms!formKey!txtKeyID;
    Very simple. It returns a column of values based on who I've assigned keys to. It works.

    When I don't have the form open, it asks for the value of Forms!formKey!t xtKeyID, and when I give it that value manually, it returns the list of associated UIDs.

    qryKe...
    See more | Go to post

  • mbedford
    replied to Use query to populate a table
    I resolved this issue by generalizing the SELECT statement and removing the WHERE clause.

    Now qryPrintCostMas ter returns all records correctly modified in a neat table.
    See more | Go to post

    Leave a comment:


  • mbedford
    started a topic Use query to populate a table

    Use query to populate a table

    I've built a series of queries that bring together and process data from several different tables and queries and at the end a single query returns a single record based on a selection made in a form.

    I've built myself into a bit of a bind, however, in that the queries begin by referencing the value in a control in the form, and the form itself is based on the query. This circular setup is not working. Obviously.

    In...
    See more | Go to post

  • mbedford
    replied to SQL query no results
    Ok, figured this out with the pointers you gave, Oralloy. Thank you.

    I want to be able to do more things with the two queries qryPrintCostSup port and qryPrintCostMet er, so the fix had to work by that point in the query ladder.

    So I changed the INNER JOINs in those two queries to RIGHT JOINs (which Access trimmed down from RIGHT OUTER JOINs that I'd typed). When there is no data in either tblSupport or tblPrinterMeter...
    See more | Go to post

    Leave a comment:


  • mbedford
    replied to SQL query no results
    Is the syntax the same for INNER and OUTER joins?

    What are the substantive differences between the two?

    What are examples of times one and the other are appropriate?
    See more | Go to post

    Leave a comment:


  • mbedford
    started a topic SQL query no results

    SQL query no results

    How can I make a query return zero values when there are no results?

    The first level of queries returns data from tables based on a selection made in a form and reported in a different query.

    The base query, qryPrintCostAss ets, returns all data from tblAssets based on a selection in a form. qryPrintCostAss ets.ID is key to the rest of the queries pulling their data.

    Code:
    SELECT *
    FROM tblAssets
    ...
    See more | Go to post

  • Query/Form pull from several tables, multiple common fields

    I'm buildling a form for tracking printer costs. This form will display data from several different tables pulled together by queries.

    formPrintCost will display:
    • printer information from tblAssets
    • support, maintenance, downtime and supply information and costs from tblSupport
    • page counts from tblPrinterMeter


    The main control in formPrintCost is listPrinter, which is a List Box with all the printers in tblAssets....
    See more | Go to post

  • mbedford
    replied to Query dependent on different query
    Steven,

    Thanks. I just got it figured out based on your instructions and it appears to be working now as I wanted.
    See more | Go to post

    Leave a comment:


  • mbedford
    started a topic Query dependent on different query

    Query dependent on different query

    I have a table that has data from several different forms. Prior to building the form, I thought the best idea was to create several queries that pull all the data together from the various forms based on various selections.

    The difficulty lies in that there is not a single common field for all the involved tables.

    The most central table is tblAssets, which has the following fields important to the question:
    ...
    See more | Go to post

  • I wondered how that ended up being incorrect as what I'd done is added the info from that link above to the Query Builder view (not my favorite, I read the SQL better) and then viewed the SQL output which was as I posted above.

    However, doing as you instructed and finding a few extraneous parens causing missing operator errors, I came up with this code:
    Code:
    SELECT tblAssets.ID, IIf(Not IsNull(tblAssets.NetName),tblAssets.NetName,tblAssets.ModelID)
    ...
    See more | Go to post

    Leave a comment:


  • Ok, an addendum question here:

    If cboUID is blank, I want all possible records returned.

    Based on the instructions here: http://www.databasedev.co.uk/blank_query_parameter.html

    I came up with the following code:

    Code:
    SELECT tblAssets.ID, IIf(Not IsNull(tblAssets.NetName),tblAssets.NetName,tblAssets.ModelID) AS Name, tblAssets.SN
    FROM tblAssets
    WHERE (((tblAssets.UID)=[Forms]![formSupport]![cboUID])
    ...
    See more | Go to post

    Leave a comment:


  • Excellent! That worked perfectly. And now I've got a bit of knowledge of SQL conditionals. Thank you very much.
    See more | Go to post

    Leave a comment:


  • OldBirdman, the only issue is that ModelID is always filled. Networked assets have ModelID entries in addition to the NetName entry.

    The logic is similar to an If... Else. IF NetName Is Not Null, NetName as Name. Else, ModelID as Name.

    Can that be translated into a single query?
    See more | Go to post

    Leave a comment:


  • I'm trying the multi-query method right now.

    qryAssetsModelI D returns all entries where NetName is NULL with the fields labeled appropriately for further use:
    Code:
    SELECT tblAssets.ID, tblAssets.ModelID AS Name, tblAssets.UID
    FROM tblAssets
    WHERE (((tblAssets.NetName) Is Null) AND ((tblAssets.Status)="In Use" Or (tblAssets.Status)="Open" Or (tblAssets.Status)="Repair" Or (tblAssets.Status)="Stored"));
    ...
    See more | Go to post

    Leave a comment:


  • mbedford
    started a topic Access 2003 SQL Conditional SELECT Statement

    Access 2003 SQL Conditional SELECT Statement

    Structure:
    Table: tblAssets
    Fields: ID, UID, ModelID, NetName

    I'm trying to populate a query which I'll then use for the source of a Combo Box in a form.

    The query will return two fields from three fields in tblAssets: ID (which each asset entry has) and Name, which defaults to NetName (for workstations and printers) and to ModelID (for furniture and non-networked assets) if NetName is empty.
    ...
    See more | Go to post

  • mbedford
    replied to Form/Subform interaction
    Ok, I found how I was misunderstandin g your instructions.

    I was assuming by "Form" you meant the name of my form, as in "formSuppor t".

    So, I modified my code to use the Form control action. It's working very well now thanks.
    See more | Go to post

    Leave a comment:


  • mbedford
    replied to Form/Subform interaction
    Perhaps the best question is: What is the best resource you have found for listing and describing the various event triggers and what types of controls they can be used on?
    See more | Go to post

    Leave a comment:


  • mbedford
    replied to Form/Subform interaction
    So using the OnCurrent for a form event in place of the AfterUpdate on the ID:

    Code:
    Private Sub formSupport_OnCurrent()
    
    On Error GoTo Err_Update_Click
    
        Me![listAssetSupportHistory].Requery
        Me![listUserSupportHistory].Requery
        
    Exit_Update_Click:
        Exit Sub
    
    Err_Update_Click:
        MsgBox Err.Description
        Resume Exit_Update_Click
    ...
    See more | Go to post

    Leave a comment:


  • mbedford
    started a topic Form/Subform interaction

    Form/Subform interaction

    I'm building a db for tracking support issues.

    The form has two lists which I want to update based on selections elsewhere in the form, and I want to open selected records in the form when selections in the lists are double clicked.

    The details:
    ID - Autonumber field used as support ID
    cboUID - User ID
    cboAssetID - Asset ID

    listAssetSuppor tHistory
    listUserSupport History
    ...
    See more | Go to post

  • I would also like to add some If/Then logic to the cboDept to change the behavior of cbosubDept based on whether or not there are subDepts for the selection in cboDept.

    Something along the lines of:

    Code:
    Private Sub cboDept_AfterUpdate() 
        ' Filter records in cboSubDept based on selection in cboDept 
        Dim subDeptSource As String 
      
        If Me.cboDept.Value (does not equal null)
    ...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...