Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 37
  1. #16
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    I agree with June about "why bother". The standard way is easy and achieves the need.

  2. #17
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    It just seems like an odd way to do it. There's too many fields on some of the forms to simply have unbound and their respective bound fields on the same form. I think I'll just pass the results to a new form and have both forms mimic each other in a way so they look the same with some minor differences. Since I wasn't getting my results back 100% correctly, I'll likely be back later today to get further help in that regard. It is mostly in regards to non-text fields.

  3. #18
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Normally, the number of filter fields is vastly smaller than the number of fields to be displayed for update. Also, the filter fields are generally NOT fields that are going to be updated - for example, the client company ID, the type of invoice, the date range. If every record to be displayed all have the same value for those fields, and if the fields will not be updated, then there is no reason to display them on the subform/detail form. The classic example would be a form that allows you to look at all the invoices for a particular client. The top of the form allows you to pick the client, and the bottom displays the invoices.

    Your idea of passing forward the results is just fine. You'll probably want a command button to cause the form to open, and it's your call whether to try to pass the user back to the filter form afterwards.

  4. #19
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    I got the search working but when I click on a button to go to the next record it seems to add in a blank record at the end of the results. Once I click on go to the next record again, it says it can't since there are no more. In other words, if I do a search and should get one record back, it returns two with one of them being blank.

    Edit: Fixed.

  5. #20
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    How do I search for the time?

  6. #21
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Do you want to search for a particular hour of any and all dates or just the hour on a specific date?

    Do you understand that date/time value in a Date/Time type field is actually stored as a number?

    Are you using the Allen Browne code method?
    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.

  7. #22
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    The dates are a separate field. I'm looking for any time within the short time format. I am using the Allen Browne method, which I did have to tweak since the check box code wasn't working for what I wanted.

  8. #23
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The date and time parts are in separate fields? The fields are Date/Time type?

    User inputs something like 15:23 into unbound search textbox?

    If a Date/Time type field contains only time part, Access will assume a date of 1/1/1899.

    So the string construction will be like:

    "Format([fieldname], 'Short Time')='" & Me.textbox & "'"

    Or create a field in query that is the RecordSource for form or report that calculates the short time and apply the filter criteria to that constructed field:

    "[fieldname]='" & Me.textBox & "'"

    Use the apostrophe delimiters because the values are text, not date/time.
    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.

  9. #24
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    How do I add in the "AND" at the end? This gives me an error.

    Code:
    strWhere = strWhere & "([C05] >= " & Format([Me.C05], 'Short Time')='" & Me.C05 & AND "'"

  10. #25
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    strWhere = strWhere & "([C05] >= " & Format([Me.C05], 'Short Time')='" & Me.C05 & "' AND "
    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.

  11. #26
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    The code text still goes red after I go to another line.

  12. #27
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Sorry, I didn't look at the rest of the expression. Why is [C05] field referenced twice (that was not in my suggestion)? The expression is nonsensical.

    strWhere = strWhere & " Format([Me.C05], 'Short Time')>='" & Me.C05 & "' AND "
    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.

  13. #28
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    1) As standard practice, when building a complex condition, I would include the "AND" at the beginning of each clause after the first, rather than at the end of the previous clause. For the first clause, I would begin with either "WHERE ", or nothing, depending on whether the SQL was being used as a filter or an entire query.

    2) Also as standard practice, I would make sure that the controls on the form do NOT have the same name as the fields on the database. I know that's the default for MS, but making them different clarifies what item is being referred to in any given line of code.

    3)
    If your database is storing exact times, and you want to search on time, then you may need a more complex condition.
    Searching for times can be pretty squirrely. If those are exact times in your database, then you probably want to generate a test like "[Mytimefield] between X and Y", where X and Y are mathematically generated from the time field on the form. You can use the Hour function to make this easy.
    Code:
    " (Hour([C05]) BETWEEN " & (Hour(Me.C05) - 1) & " AND " & (Hour(Me.C05) + 1) & ") AND "

  14. #29
    WithoutPause is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    62
    When I run the application as is and do a search, the resulting form only shows the form header info and the Detail part is left blank. If I use a break point to see what is going on, the search runs fine and everything shows up correctly. If I click on the Toggle Filter button, the form shows up with unfiltered data. If I click it again, the form shows up with the correct data for my search.

    There seems to be a similar issue when I am passing data from one form to another without doing a search. The first time the new form opens, the data isn't showing. If I go back to the previous screen and retry, the data shows up. Again, if I do it the first time and click on the Toggle Filter button twice, my data shows up.

    Also, if there is no search criteria, how can I have it return all records?

  15. #30
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Options:

    1. parameterized query using LIKE and wildcard

    2. If there is no criteria input then don't set Filter property, and set the FilterOn property to False
    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.

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to Input Multiple Same Fields in one form?
    By butterbescotch in forum Forms
    Replies: 1
    Last Post: 11-01-2013, 01:15 AM
  2. Searching Using a Query in Multiple Fields
    By RossIV in forum Queries
    Replies: 10
    Last Post: 07-24-2013, 06:32 AM
  3. Input Forms - How To Input Multiple Fields/Records?
    By butterbescotch in forum Forms
    Replies: 1
    Last Post: 04-04-2013, 06:30 AM
  4. Replies: 1
    Last Post: 01-12-2012, 04:05 AM
  5. Replies: 8
    Last Post: 12-05-2011, 01:55 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