Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

NotInList

Discussion in 'Information Technology' started by Levans digital, Jul 28, 2006.

Tags:
  1. Levans digital

    Levans digital
    Expand Collapse
    Guest

    Hi there,
    I am having problems with a NotInList event

    Below is what I have:
    Private Sub ContainerID_NotInList(NewData As String, Response As Integer)
    Dim strName As String, strWhere As String

    strName = NewData
    strWhere = "[ContainerID] = '" & strName & "'"

    If vbYes = MsgBox("Container Number " & NewData & " is not defined. " & _
    "Do you want to add this Number?", vbYesNo + vbQuestion +
    vbDefaultButton2, gstrAppTitle) Then

    DoCmd.OpenForm "ContainerNofrm", DataMode:=acFormAdd,
    WindowMode:=acDialog, _
    OpenArgs:=strName

    If IsNull(DLookup("ContainerID", "ContainerNotbl", strWhere)) Then

    MsgBox "You failed to add a Container Number that matched what
    you entered. Please try again.", vbInformation, gstrAppTitle

    Response = acDataErrContinue
    Else

    Response = acDataErrAdded
    End If
    Else

    Response = acDataErrDisplay
    End If
    End Sub

    Aften new data is eneterd into the "ContainerNofrm" and the form is closed I
    get error message "Datatype Mismatch in query expression" when I debug the
    line below is highlighted:
    If IsNull(DLookup("ContainerID", "ContainerNotbl", strWhere)) Then

    help
     
  2. Dirk Goldgar

    Dirk Goldgar
    Expand Collapse
    Guest

    "Levans digital" <Levansdigital@discussions.microsoft.com> wrote in
    message news:9A39A2EC-C4B1-4E1C-8974-AB5D5B7B4DE1@microsoft.com
    > Hi there,
    > I am having problems with a NotInList event
    >
    > Below is what I have:
    > Private Sub ContainerID_NotInList(NewData As String, Response As
    > Integer) Dim strName As String, strWhere As String
    >
    > strName = NewData
    > strWhere = "[ContainerID] = '" & strName & "'"
    >
    > If vbYes = MsgBox("Container Number " & NewData & " is not
    > defined. " & _ "Do you want to add this Number?", vbYesNo +
    > vbQuestion +
    > vbDefaultButton2, gstrAppTitle) Then
    >
    > DoCmd.OpenForm "ContainerNofrm", DataMode:=acFormAdd,
    > WindowMode:=acDialog, _
    > OpenArgs:=strName
    >
    > If IsNull(DLookup("ContainerID", "ContainerNotbl", strWhere))
    > Then
    >
    > MsgBox "You failed to add a Container Number that matched
    > what you entered. Please try again.", vbInformation, gstrAppTitle
    >
    > Response = acDataErrContinue
    > Else
    >
    > Response = acDataErrAdded
    > End If
    > Else
    >
    > Response = acDataErrDisplay
    > End If
    > End Sub
    >
    > Aften new data is eneterd into the "ContainerNofrm" and the form is
    > closed I get error message "Datatype Mismatch in query expression"
    > when I debug the line below is highlighted:
    > If IsNull(DLookup("ContainerID", "ContainerNotbl", strWhere)) Then
    >
    > help


    What type of field is ContainerID? If it's a number field, the value
    taken from NewData should not be enclosed in quotes. So instead of
    this:

    > strWhere = "[ContainerID] = '" & strName & "'"


    .... write this:

    strWhere = "[ContainerID] = " & strName

    --
    Dirk Goldgar, MS Access MVP
    www.datagnostics.com

    (please reply to the newsgroup)
     
  3. Levans digital

    Levans digital
    Expand Collapse
    Guest

    Hey Dirk,
    Thanksmuch your a genious it works great.

    "Dirk Goldgar" wrote:

    > "Levans digital" <Levansdigital@discussions.microsoft.com> wrote in
    > message news:9A39A2EC-C4B1-4E1C-8974-AB5D5B7B4DE1@microsoft.com
    > > Hi there,
    > > I am having problems with a NotInList event
    > >
    > > Below is what I have:
    > > Private Sub ContainerID_NotInList(NewData As String, Response As
    > > Integer) Dim strName As String, strWhere As String
    > >
    > > strName = NewData
    > > strWhere = "[ContainerID] = '" & strName & "'"
    > >
    > > If vbYes = MsgBox("Container Number " & NewData & " is not
    > > defined. " & _ "Do you want to add this Number?", vbYesNo +
    > > vbQuestion +
    > > vbDefaultButton2, gstrAppTitle) Then
    > >
    > > DoCmd.OpenForm "ContainerNofrm", DataMode:=acFormAdd,
    > > WindowMode:=acDialog, _
    > > OpenArgs:=strName
    > >
    > > If IsNull(DLookup("ContainerID", "ContainerNotbl", strWhere))
    > > Then
    > >
    > > MsgBox "You failed to add a Container Number that matched
    > > what you entered. Please try again.", vbInformation, gstrAppTitle
    > >
    > > Response = acDataErrContinue
    > > Else
    > >
    > > Response = acDataErrAdded
    > > End If
    > > Else
    > >
    > > Response = acDataErrDisplay
    > > End If
    > > End Sub
    > >
    > > Aften new data is eneterd into the "ContainerNofrm" and the form is
    > > closed I get error message "Datatype Mismatch in query expression"
    > > when I debug the line below is highlighted:
    > > If IsNull(DLookup("ContainerID", "ContainerNotbl", strWhere)) Then
    > >
    > > help

    >
    > What type of field is ContainerID? If it's a number field, the value
    > taken from NewData should not be enclosed in quotes. So instead of
    > this:
    >
    > > strWhere = "[ContainerID] = '" & strName & "'"

    >
    > .... write this:
    >
    > strWhere = "[ContainerID] = " & strName
    >
    > --
    > Dirk Goldgar, MS Access MVP
    > www.datagnostics.com
    >
    > (please reply to the newsgroup)
    >
    >
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page