#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Question Problem with VB access 2010 script


    Hi
    I created VB script under Access 2010 to look up for record in two different forms, and when is a match, then open correct form with specific record present, also if record was not found it should show message, but is not working. It looks like my "IF" statement is wrong.
    Can you help me find what is wrong?
    Thnak you
    Tytus

    **************
    Private Sub Command22_Click()


    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "CHANGE_CONTROL_DOCUMENTS"

    If (stLinkCriteria = "[Document ID]=" & "'" & Me![Document_type] & "'") <> 0 Then

    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Else

    MsgBox "The Document does not exist!", vbCritical

    End If


    End Sub
    ***************
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0

    Question


    Hi
    I was able to fix some stuff in my script, so is looking correctly for records in two differnet forms, only one thing is still not good that when there is no record to match, is not displaying my message.
    Any advice?
    #
    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim stDocNameF As String
    Dim stDocNameALL As String
    Dim CDWM As String
    Dim Base As String
    Dim i As String

    stDocName = "DOC-1"
    stDocNameF = "DOC-2"
    Str1 = "CDWM"
    Str2 = "Base"
    stLinkCriteria = "[Document ID]=" & "'" & Me![Document_type] & "'"

    If InStr(stLinkCriteria, Str1) > 0 Then

    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Else
    If InStr(stLinkCriteria, Str2) > 0 Then

    DoCmd.OpenForm stDocNameF, , , stLinkCriteria
    Else
    MsgBox "The directory already exist!", vbCritical
    End If
    End If
    #

IMN logo majestic logo threadwatch logo seochat tools logo