Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 34
  1. #16
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    Yey! Almost there!

    One little glinch though...

    When I search for i.e. in use, it forgets the columns that are based from other tables. Like cathegory. I have cathegorys like Pc, Camera, Speakers in a table and in the main table I can chose from these categorys to save to a specific equipment. Now it just shows #Name? or show the ID of the post in the linked table... This worked before.

  2. #17
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    So modify the SQL statement to link in that secondary field

    Instead of "SELECT * FROM TableName WHERE InUse = -1"

    You'd have to use a SQL statement that included the secondary table. If you're not comfortable building the SQL statement, write a query that shows you what you want, then copy that SQL statement into your code.

  3. #18
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    I already have a query (qrySearch) that is called by the search button and it does what it's supposed to. Do you suggest that instead of using the query I should use SQL in the OnClick for the button?

  4. #19
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    No, your qrySearch doesn't do what you want. It's a generic query that shows everything that would work for your "SHOW ALL" option, but you have to modify that SQL statement for your SHOW IN USE and SHOW NOT IN USE options

  5. #20
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    Ok, I will try that in a couple of days. Now we are having easter holydays in Sweden so I'm back at work in 4 days and will try this.
    I'll see you then! Thanks for now!

  6. #21
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    Hi again!

    How do I transfer the query code into SQL? I have a statement

    LIKE [Forms]![frmSearch].[qProductID1] & "*"

    in qrySearch that is called when I click the Search button.

  7. #22
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    "SELECT * FROM TableName WHERE [FieldName] Like '" & pforms!frmsearch!qproductid1 & "*'"

  8. #23
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    And do I need to do this for every text field I have in the search form?

  9. #24
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You can build your SQL statement to look at whatever fields you want based on what a user has checked off, typed in or selected from combo boxes/list boxes. You just have to apply a little logic. So if you have given them 5 search boxes 4 of which are text fields 1 of which is a number field you have to test each field to see if it's null or blank and if it's not add an appropriate statement to your WHERE string.

  10. #25
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    I typed this:

    "SELECT * FROM tblUnit WHERE ProductID LIKE '& forms!frmSearch!qProductID1 & '*'"

    but I get a compilation error saying sometihing like expected row number, row label, string or end of string.

  11. #26
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    well that's not the syntax I gave you

    If your qProductID1 is a text field you can use the LIKE statement, if it's a number you can't.

    if it is in fact text the syntax is:

    "SELECT * FROM tblUnit WHERE ProductID LIKE '" & forms!frmSearch!qProductID1 & "*'"

  12. #27
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    It's a number, but in the query I can use like. What should I write then?

  13. #28
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    "SELECT * FROM tblUnit WHERE ProductID = " & forms!frmSearch!qProductID1

    Assuming that your field qPRODUCTID1 contains (if it's a combo box the bound column is..) a number.

  14. #29
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    Me!frmSearchSub.Form.RecordSource = "SELECT * FROM tblUnit WHERE ProductID = " & Forms!frmSearch!qProductID1

    gives me runtime error 3463 data type mismatch... But ProductID are numbers...

  15. #30
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    use your debug.print messages to see if it's building the SQL statement you want


    dim sSQL as string

    sSQL = "SELECT * FROM tblUnit WHERE ProductID = " & forms!frmSearch!qProductID1
    debug.print sSQL

    if your qPRODUCTID field is a combo box or list box it may not be looking at the column you think it is.

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

Similar Threads

  1. Radio Buttons
    By maguyver in forum Access
    Replies: 3
    Last Post: 07-07-2012, 10:39 AM
  2. Radio Buttons
    By ccordner in forum Forms
    Replies: 1
    Last Post: 01-27-2012, 09:56 AM
  3. Radio Buttons
    By neil123williams in forum Forms
    Replies: 8
    Last Post: 11-11-2011, 03:38 PM
  4. what happened to radio buttons?
    By judomum in forum Forms
    Replies: 1
    Last Post: 10-09-2011, 11:58 AM
  5. radio buttons from 97 to 2010
    By mmm in forum Access
    Replies: 0
    Last Post: 12-03-2010, 04:20 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