Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wherecondition (2000)

    I have the following code but I get the following error when it is run:

    Dim cnn As ADODB.Connection
    Dim rst As New ADODB.Recordset
    Dim varsalesid As Variant
    Dim strlogon As String

    'Find logon information
    strlogon = Environ("Username")
    varsalesid = DLookup("[SALESID]", "tblsalesman", "Winlogon=" & Chr(34) & strlogon & Chr(34))
    OfficeResID = DLookup("[valuerbased]", "tblValuer", "ValuerID=" & Me!ValuerID)

    If IsNull(Me!PropertyDB) = True Then

    Set cnn = CurrentProject.Connection
    rst.Open "tblProperty", cnn, adOpenKeyset, adLockOptimistic, adCmdTableDirect
    rst.AddNew
    rst!PROPNUMR = Me!VHouseNo
    rst!STREETNAME = Me!VStreetName
    rst!ADDRESS2 = Me!VStreet2
    rst!AREA = Me!VArea
    rst!CITY = VCity
    rst!POSTCODE = Me!VPostcode
    rst!VENDORTEL1 = Me!HomeTel
    rst!VENDORTEL2 = Me!WorkTel
    rst!VMobile = Me!MobileTel
    rst!CAddress1 = Me!CHouseNo & " " & Me!CStreetName
    rst!CAddress2 = Me!CStreet2
    rst!CAddress3 = Me!CArea
    rst!CTown = Me!CCity
    rst!CPostcode = Me!CPostcode
    rst!OfficeID = OfficeResID
    rst!VTitle1 = Me!Title1
    rst!VTitle2 = Me!Title2
    rst!VFName1 = Me!FName1
    rst!VFname2 = Me!FName2
    rst!VSurname1 = Me!Surname1
    rst!VSurname2 = Me!Surname2
    rst!Email = Me!EmailAddress
    rst.Update
    rst.Save
    rst.Close

    Set rst = Nothing
    Set cnn = Nothing

    msgbox "The property has now been entered into the database"

    Else

    msgbox "The property has already been entered"

    End If


    DoCmd.OpenForm "frmProperty", acNormal, , "propnumr=" & Me!VHouseNo & " and streetname=" & Me!VStreetName
    Best Regards,

    Luke

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Wherecondition (2000)

    Since streetname is a text field, you must enclose the value in quotes, as is already done with strlogon in your code.

    DoCmd.OpenForm "frmProperty", acNormal, , "propnumr=" & Me!VHouseNo & " and streetname=" & Chr(34) & Me!VStreetName & Chr(34)

Posting Permissions

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