Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2006
    Posts
    23

    Unanswered: Using forms for Queries

    Hi Guys,

    Does anyone have any advice on how to set up a query using a form? I can use the access wizards to perform queries, however would like to add this functionality to a form.

    With the database I have created I want to search for Topic Names, hopefully by the users inputting the string into a text box, and then if the topic name exists, returning this form, if not returing an message saying that it doesnt exist. Any help would be much appreciated,

    Ross

  2. #2
    Join Date
    Jan 2006
    Location
    Washington, D.C
    Posts
    29
    Quote Originally Posted by rcwilkinson
    Hi Guys,

    Does anyone have any advice on how to set up a query using a form? I can use the access wizards to perform queries, however would like to add this functionality to a form.

    With the database I have created I want to search for Topic Names, hopefully by the users inputting the string into a text box, and then if the topic name exists, returning this form, if not returing an message saying that it doesnt exist. Any help would be much appreciated,

    Ross
    The besy way to do it is to pass it to the record source. You can do it in a form or report

    Code:
    Public sub button_click()
    sSql = "Select * from Table WHERE TopicNames = " & quotedstr(textbox.value)
    
    Me.RecordSource = sSql
    Me.Requery
    
    or call it from a form like so
    
    Form_FormName.RecordSource = sSql
    end sub
    
    ' used to put quotes around text in SQL
    Public Function quotedStr(ByVal str As String)
    quotedStr = """" & str & """"
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •