Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2004
    Posts
    277

    Unanswered: Where, Parameter Value pops up on Open

    I am trying to open a form where the first name is equal to what is in the textbox

    Dim where1
    Dim Text1 As String
    Text3.SetFocus
    Text1 = Text3.Text
    where1 = "Contacts.FirstName" & "=" & Text1

    DoCmd.OpenForm "contacts", , , where1

    Any idea why the parameter box pops up?

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Could it be because you're trying to filter on a STRING without the required quotations?????
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    A few things...
    You should make sure that text1 doesn't just evaluate to "". That's what
    you'll get if there is no value in the Text3 field.

    Try changing your where1 string to this:
    where1 = "Contacts.FirstName='" & Text1 & "'"
    Inspiration Through Fermentation

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Parameter

    I don't understand why all the extra code. Wouldn't it be just as easy to have something like this:

    Dim txtName As String
    txtName = Me!NameField
    DoCmd.OpenForm "Contacts", , , "FirstName = '" & txtName & "'"

    or

    Docmd.OpenForm "Contacts", , , "FirstName = '" & Forms!MyOldForm!NameField & "'"

    Maybe I'm missing something.
    Last edited by pkstormy; 02-28-05 at 16:50.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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