Welcome to SPN

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

Sign Up Now!

if clause in access 2000

Discussion in 'Information Technology' started by lula, Nov 3, 2005.

Tags:
  1. lula

    lula
    Expand Collapse
    Guest

    hi there... sorry... I'm very very new at access 2000 and I cannot figure out
    how I can do an if clause.

    this is what's going on... I have a form that shows information about
    computers (form1). I have another form (form2) that contains information
    about computer repair requests(CRR). I have a button on form1 that brings me
    the CRR for the computer that the form1 is showing at that moment. but what I
    need is that If there's no CRR for that computer, to display a message
    saying: no CRR for that computer....

    I wanted to do that with an if clause in the button properties, but I'm so
    dumb that I cannot figure it out.....

    can you help me please??? I'm sure that is going to be very easy for all of
    you

    thanks
     
  2. Loading...


  3. RuralGuy

    RuralGuy
    Expand Collapse
    Guest

    If you do not want to open the Form2 when no CRR exists then I would
    suggest a DLookup() or DCount() before OpenForm command.

    On Wed, 2 Nov 2005 11:46:01 -0800, "lula" <lula@discussions.microsoft.com>
    wrote:

    >hi there... sorry... I'm very very new at access 2000 and I cannot figure out
    >how I can do an if clause.
    >
    >this is what's going on... I have a form that shows information about
    >computers (form1). I have another form (form2) that contains information
    >about computer repair requests(CRR). I have a button on form1 that brings me
    >the CRR for the computer that the form1 is showing at that moment. but what I
    >need is that If there's no CRR for that computer, to display a message
    >saying: no CRR for that computer....
    >
    >I wanted to do that with an if clause in the button properties, but I'm so
    >dumb that I cannot figure it out.....
    >
    >can you help me please??? I'm sure that is going to be very easy for all of
    >you
    >
    >thanks

    _______________________________________________
    hth - RuralGuy (RG for short)
    Please post to the NewsGroup so all may benefit.
     
  4. Ofer

    Ofer
    Expand Collapse
    Guest

    Use the Dcount to see if there are any records in the table before you open
    form2

    If Dcount("*", "TableName","[computer Field Name In the table] = '" & Me![
    computer Field Name In the form] & "'") = 0 then
    msgbox "No records for this computer"
    else
    docmd.openform "Form2"
    End if
    --
    If I answered your question, please mark it as an answer. That way, it will
    stay saved for a longer time, so other can benefit from it.

    Good luck



    "lula" wrote:

    > hi there... sorry... I'm very very new at access 2000 and I cannot figure out
    > how I can do an if clause.
    >
    > this is what's going on... I have a form that shows information about
    > computers (form1). I have another form (form2) that contains information
    > about computer repair requests(CRR). I have a button on form1 that brings me
    > the CRR for the computer that the form1 is showing at that moment. but what I
    > need is that If there's no CRR for that computer, to display a message
    > saying: no CRR for that computer....
    >
    > I wanted to do that with an if clause in the button properties, but I'm so
    > dumb that I cannot figure it out.....
    >
    > can you help me please??? I'm sure that is going to be very easy for all of
    > you
    >
    > thanks
     
  5. lula

    lula
    Expand Collapse
    Guest

    hey thanx....I'm not sure if I know how to do that Dlookup() or the
    DCount()... I just tried to do it, and my access went nuts.. haha

    can't I just do like:
    stLinkCriteria = "[id_tag]=" & Me![id_tag]
    If stLinkCriteria <> Null Then DoCmd.OpenForm CRR, , , stLinkCriteria
    if not show message or something like that???

    but how can I write that "if not" part or else???

    thank you for your help!

    "RuralGuy" wrote:

    > If you do not want to open the Form2 when no CRR exists then I would
    > suggest a DLookup() or DCount() before OpenForm command.
    >
    > On Wed, 2 Nov 2005 11:46:01 -0800, "lula" <lula@discussions.microsoft.com>
    > wrote:
    >
    > >hi there... sorry... I'm very very new at access 2000 and I cannot figure out
    > >how I can do an if clause.
    > >
    > >this is what's going on... I have a form that shows information about
    > >computers (form1). I have another form (form2) that contains information
    > >about computer repair requests(CRR). I have a button on form1 that brings me
    > >the CRR for the computer that the form1 is showing at that moment. but what I
    > >need is that If there's no CRR for that computer, to display a message
    > >saying: no CRR for that computer....
    > >
    > >I wanted to do that with an if clause in the button properties, but I'm so
    > >dumb that I cannot figure it out.....
    > >
    > >can you help me please??? I'm sure that is going to be very easy for all of
    > >you
    > >
    > >thanks

    > _______________________________________________
    > hth - RuralGuy (RG for short)
    > Please post to the NewsGroup so all may benefit.
    >
     
  6. Ofer

    Ofer
    Expand Collapse
    Guest

    Have you looked at my example

    If Dcount("*", "TableName","[id_tag]=" & Me![id_tag]) = 0 then
    msgbox "No records for this computer"
    else
    docmd.openform "Form2"
    End if

    --
    If I answered your question, please mark it as an answer. That way, it will
    stay saved for a longer time, so other can benefit from it.

    Good luck



    "lula" wrote:

    > hey thanx....I'm not sure if I know how to do that Dlookup() or the
    > DCount()... I just tried to do it, and my access went nuts.. haha
    >
    > can't I just do like:
    > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > If stLinkCriteria <> Null Then DoCmd.OpenForm CRR, , , stLinkCriteria
    > if not show message or something like that???
    >
    > but how can I write that "if not" part or else???
    >
    > thank you for your help!
    >
    > "RuralGuy" wrote:
    >
    > > If you do not want to open the Form2 when no CRR exists then I would
    > > suggest a DLookup() or DCount() before OpenForm command.
    > >
    > > On Wed, 2 Nov 2005 11:46:01 -0800, "lula" <lula@discussions.microsoft.com>
    > > wrote:
    > >
    > > >hi there... sorry... I'm very very new at access 2000 and I cannot figure out
    > > >how I can do an if clause.
    > > >
    > > >this is what's going on... I have a form that shows information about
    > > >computers (form1). I have another form (form2) that contains information
    > > >about computer repair requests(CRR). I have a button on form1 that brings me
    > > >the CRR for the computer that the form1 is showing at that moment. but what I
    > > >need is that If there's no CRR for that computer, to display a message
    > > >saying: no CRR for that computer....
    > > >
    > > >I wanted to do that with an if clause in the button properties, but I'm so
    > > >dumb that I cannot figure it out.....
    > > >
    > > >can you help me please??? I'm sure that is going to be very easy for all of
    > > >you
    > > >
    > > >thanks

    > > _______________________________________________
    > > hth - RuralGuy (RG for short)
    > > Please post to the NewsGroup so all may benefit.
    > >
     
  7. lula

    lula
    Expand Collapse
    Guest

    thank you for your help... I'm still trying to work it out. it still openning
    the same form even with that Dcount function... I'm sure that will work, but
    I must be putting something wrong... hahaa....

    still working....but thanks anyways...

    "Ofer" wrote:

    > Use the Dcount to see if there are any records in the table before you open
    > form2
    >
    > If Dcount("*", "TableName","[computer Field Name In the table] = '" & Me![
    > computer Field Name In the form] & "'") = 0 then
    > msgbox "No records for this computer"
    > else
    > docmd.openform "Form2"
    > End if
    > --
    > If I answered your question, please mark it as an answer. That way, it will
    > stay saved for a longer time, so other can benefit from it.
    >
    > Good luck
    >
    >
    >
    > "lula" wrote:
    >
    > > hi there... sorry... I'm very very new at access 2000 and I cannot figure out
    > > how I can do an if clause.
    > >
    > > this is what's going on... I have a form that shows information about
    > > computers (form1). I have another form (form2) that contains information
    > > about computer repair requests(CRR). I have a button on form1 that brings me
    > > the CRR for the computer that the form1 is showing at that moment. but what I
    > > need is that If there's no CRR for that computer, to display a message
    > > saying: no CRR for that computer....
    > >
    > > I wanted to do that with an if clause in the button properties, but I'm so
    > > dumb that I cannot figure it out.....
    > >
    > > can you help me please??? I'm sure that is going to be very easy for all of
    > > you
    > >
    > > thanks
     
  8. Ofer

    Ofer
    Expand Collapse
    Guest

    can you post your code, please?
    --
    If I answered your question, please mark it as an answer. That way, it will
    stay saved for a longer time, so other can benefit from it.

    Good luck



    "lula" wrote:

    > thank you for your help... I'm still trying to work it out. it still openning
    > the same form even with that Dcount function... I'm sure that will work, but
    > I must be putting something wrong... hahaa....
    >
    > still working....but thanks anyways...
    >
    > "Ofer" wrote:
    >
    > > Use the Dcount to see if there are any records in the table before you open
    > > form2
    > >
    > > If Dcount("*", "TableName","[computer Field Name In the table] = '" & Me![
    > > computer Field Name In the form] & "'") = 0 then
    > > msgbox "No records for this computer"
    > > else
    > > docmd.openform "Form2"
    > > End if
    > > --
    > > If I answered your question, please mark it as an answer. That way, it will
    > > stay saved for a longer time, so other can benefit from it.
    > >
    > > Good luck
    > >
    > >
    > >
    > > "lula" wrote:
    > >
    > > > hi there... sorry... I'm very very new at access 2000 and I cannot figure out
    > > > how I can do an if clause.
    > > >
    > > > this is what's going on... I have a form that shows information about
    > > > computers (form1). I have another form (form2) that contains information
    > > > about computer repair requests(CRR). I have a button on form1 that brings me
    > > > the CRR for the computer that the form1 is showing at that moment. but what I
    > > > need is that If there's no CRR for that computer, to display a message
    > > > saying: no CRR for that computer....
    > > >
    > > > I wanted to do that with an if clause in the button properties, but I'm so
    > > > dumb that I cannot figure it out.....
    > > >
    > > > can you help me please??? I'm sure that is going to be very easy for all of
    > > > you
    > > >
    > > > thanks
     
  9. lula

    lula
    Expand Collapse
    Guest

    thank you.....

    this is the one I put in after your idea.....


    Private Sub CmdOpenCRRFrm_Click()
    On Error GoTo Err_CmdOpenCRRFrm_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "CRRFiltered"

    stLinkCriteria = "[id_tag]=" & Me![id_tag]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    If DCount("*", "CRR", "[id_tag] = '" & Me![id_tag] & "'") = 0 Then
    MsgBox "No records for this computer"
    Else
    DoCmd.OpenForm "CRRFiltered"
    End If

    Exit_CmdOpenCRRFrm_Click:
    Exit Sub

    Err_CmdOpenCRRFrm_Click:
    MsgBox Err.description
    Resume Exit_CmdOpenCRRFrm_Click

    End Sub

    this is the one I had at the beginning showing the CRR even if it didn't
    have any CRR attached to the computer.
    Private Sub CmdOpenCRRFrm_Click()
    On Error GoTo Err_CmdOpenCRRFrm_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "CRRFiltered"

    stLinkCriteria = "[id_tag]=" & Me![id_tag]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Exit_CmdOpenCRRFrm_Click:
    Exit Sub

    Err_CmdOpenCRRFrm_Click:
    MsgBox Err.description
    Resume Exit_CmdOpenCRRFrm_Click

    End Sub




    "Ofer" wrote:

    > can you post your code, please?
    > --
    > If I answered your question, please mark it as an answer. That way, it will
    > stay saved for a longer time, so other can benefit from it.
    >
    > Good luck
    >
    >
    >
    > "lula" wrote:
    >
    > > thank you for your help... I'm still trying to work it out. it still openning
    > > the same form even with that Dcount function... I'm sure that will work, but
    > > I must be putting something wrong... hahaa....
    > >
    > > still working....but thanks anyways...
    > >
    > > "Ofer" wrote:
    > >
    > > > Use the Dcount to see if there are any records in the table before you open
    > > > form2
    > > >
    > > > If Dcount("*", "TableName","[computer Field Name In the table] = '" & Me![
    > > > computer Field Name In the form] & "'") = 0 then
    > > > msgbox "No records for this computer"
    > > > else
    > > > docmd.openform "Form2"
    > > > End if
    > > > --
    > > > If I answered your question, please mark it as an answer. That way, it will
    > > > stay saved for a longer time, so other can benefit from it.
    > > >
    > > > Good luck
    > > >
    > > >
    > > >
    > > > "lula" wrote:
    > > >
    > > > > hi there... sorry... I'm very very new at access 2000 and I cannot figure out
    > > > > how I can do an if clause.
    > > > >
    > > > > this is what's going on... I have a form that shows information about
    > > > > computers (form1). I have another form (form2) that contains information
    > > > > about computer repair requests(CRR). I have a button on form1 that brings me
    > > > > the CRR for the computer that the form1 is showing at that moment. but what I
    > > > > need is that If there's no CRR for that computer, to display a message
    > > > > saying: no CRR for that computer....
    > > > >
    > > > > I wanted to do that with an if clause in the button properties, but I'm so
    > > > > dumb that I cannot figure it out.....
    > > > >
    > > > > can you help me please??? I'm sure that is going to be very easy for all of
    > > > > you
    > > > >
    > > > > thanks
     
  10. Ofer

    Ofer
    Expand Collapse
    Guest

    Try this

    Private Sub CmdOpenCRRFrm_Click()
    On Error GoTo Err_CmdOpenCRRFrm_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "CRRFiltered"

    stLinkCriteria = "[id_tag]=" & Me![id_tag]

    If DCount("*", "CRR", "[id_tag] = '" & Me![id_tag] & "'") = 0 Then
    MsgBox "No records for this computer"
    Else
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    End If

    Exit_CmdOpenCRRFrm_Click:
    Exit Sub

    Err_CmdOpenCRRFrm_Click:
    MsgBox Err.description
    Resume Exit_CmdOpenCRRFrm_Click

    End Sub

    --
    If I answered your question, please mark it as an answer. That way, it will
    stay saved for a longer time, so other can benefit from it.

    Good luck



    "lula" wrote:

    > thank you.....
    >
    > this is the one I put in after your idea.....
    >
    >
    > Private Sub CmdOpenCRRFrm_Click()
    > On Error GoTo Err_CmdOpenCRRFrm_Click
    >
    > Dim stDocName As String
    > Dim stLinkCriteria As String
    > stDocName = "CRRFiltered"
    >
    > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > DoCmd.OpenForm stDocName, , , stLinkCriteria
    >
    > If DCount("*", "CRR", "[id_tag] = '" & Me![id_tag] & "'") = 0 Then
    > MsgBox "No records for this computer"
    > Else
    > DoCmd.OpenForm "CRRFiltered"
    > End If
    >
    > Exit_CmdOpenCRRFrm_Click:
    > Exit Sub
    >
    > Err_CmdOpenCRRFrm_Click:
    > MsgBox Err.description
    > Resume Exit_CmdOpenCRRFrm_Click
    >
    > End Sub
    >
    > this is the one I had at the beginning showing the CRR even if it didn't
    > have any CRR attached to the computer.
    > Private Sub CmdOpenCRRFrm_Click()
    > On Error GoTo Err_CmdOpenCRRFrm_Click
    >
    > Dim stDocName As String
    > Dim stLinkCriteria As String
    > stDocName = "CRRFiltered"
    >
    > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > DoCmd.OpenForm stDocName, , , stLinkCriteria
    >
    > Exit_CmdOpenCRRFrm_Click:
    > Exit Sub
    >
    > Err_CmdOpenCRRFrm_Click:
    > MsgBox Err.description
    > Resume Exit_CmdOpenCRRFrm_Click
    >
    > End Sub
    >
    >
    >
    >
    > "Ofer" wrote:
    >
    > > can you post your code, please?
    > > --
    > > If I answered your question, please mark it as an answer. That way, it will
    > > stay saved for a longer time, so other can benefit from it.
    > >
    > > Good luck
    > >
    > >
    > >
    > > "lula" wrote:
    > >
    > > > thank you for your help... I'm still trying to work it out. it still openning
    > > > the same form even with that Dcount function... I'm sure that will work, but
    > > > I must be putting something wrong... hahaa....
    > > >
    > > > still working....but thanks anyways...
    > > >
    > > > "Ofer" wrote:
    > > >
    > > > > Use the Dcount to see if there are any records in the table before you open
    > > > > form2
    > > > >
    > > > > If Dcount("*", "TableName","[computer Field Name In the table] = '" & Me![
    > > > > computer Field Name In the form] & "'") = 0 then
    > > > > msgbox "No records for this computer"
    > > > > else
    > > > > docmd.openform "Form2"
    > > > > End if
    > > > > --
    > > > > If I answered your question, please mark it as an answer. That way, it will
    > > > > stay saved for a longer time, so other can benefit from it.
    > > > >
    > > > > Good luck
    > > > >
    > > > >
    > > > >
    > > > > "lula" wrote:
    > > > >
    > > > > > hi there... sorry... I'm very very new at access 2000 and I cannot figure out
    > > > > > how I can do an if clause.
    > > > > >
    > > > > > this is what's going on... I have a form that shows information about
    > > > > > computers (form1). I have another form (form2) that contains information
    > > > > > about computer repair requests(CRR). I have a button on form1 that brings me
    > > > > > the CRR for the computer that the form1 is showing at that moment. but what I
    > > > > > need is that If there's no CRR for that computer, to display a message
    > > > > > saying: no CRR for that computer....
    > > > > >
    > > > > > I wanted to do that with an if clause in the button properties, but I'm so
    > > > > > dumb that I cannot figure it out.....
    > > > > >
    > > > > > can you help me please??? I'm sure that is going to be very easy for all of
    > > > > > you
    > > > > >
    > > > > > thanks
     
  11. lula

    lula
    Expand Collapse
    Guest

    hi again.... I copy that code and I have a message saying that "Data type
    mismatch in criteria expression" and it's not openning any other form... do
    you know what that can be about??

    thank you for your help again!



    "Ofer" wrote:

    > Try this
    >
    > Private Sub CmdOpenCRRFrm_Click()
    > On Error GoTo Err_CmdOpenCRRFrm_Click
    >
    > Dim stDocName As String
    > Dim stLinkCriteria As String
    > stDocName = "CRRFiltered"
    >
    > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    >
    > If DCount("*", "CRR", "[id_tag] = '" & Me![id_tag] & "'") = 0 Then
    > MsgBox "No records for this computer"
    > Else
    > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > End If
    >
    > Exit_CmdOpenCRRFrm_Click:
    > Exit Sub
    >
    > Err_CmdOpenCRRFrm_Click:
    > MsgBox Err.description
    > Resume Exit_CmdOpenCRRFrm_Click
    >
    > End Sub
    >
    > --
    > If I answered your question, please mark it as an answer. That way, it will
    > stay saved for a longer time, so other can benefit from it.
    >
    > Good luck
    >
    >
    >
    > "lula" wrote:
    >
    > > thank you.....
    > >
    > > this is the one I put in after your idea.....
    > >
    > >
    > > Private Sub CmdOpenCRRFrm_Click()
    > > On Error GoTo Err_CmdOpenCRRFrm_Click
    > >
    > > Dim stDocName As String
    > > Dim stLinkCriteria As String
    > > stDocName = "CRRFiltered"
    > >
    > > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > >
    > > If DCount("*", "CRR", "[id_tag] = '" & Me![id_tag] & "'") = 0 Then
    > > MsgBox "No records for this computer"
    > > Else
    > > DoCmd.OpenForm "CRRFiltered"
    > > End If
    > >
    > > Exit_CmdOpenCRRFrm_Click:
    > > Exit Sub
    > >
    > > Err_CmdOpenCRRFrm_Click:
    > > MsgBox Err.description
    > > Resume Exit_CmdOpenCRRFrm_Click
    > >
    > > End Sub
    > >
    > > this is the one I had at the beginning showing the CRR even if it didn't
    > > have any CRR attached to the computer.
    > > Private Sub CmdOpenCRRFrm_Click()
    > > On Error GoTo Err_CmdOpenCRRFrm_Click
    > >
    > > Dim stDocName As String
    > > Dim stLinkCriteria As String
    > > stDocName = "CRRFiltered"
    > >
    > > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > >
    > > Exit_CmdOpenCRRFrm_Click:
    > > Exit Sub
    > >
    > > Err_CmdOpenCRRFrm_Click:
    > > MsgBox Err.description
    > > Resume Exit_CmdOpenCRRFrm_Click
    > >
    > > End Sub
    > >
    > >
    > >
    > >
    > > "Ofer" wrote:
    > >
    > > > can you post your code, please?
    > > > --
    > > > If I answered your question, please mark it as an answer. That way, it will
    > > > stay saved for a longer time, so other can benefit from it.
    > > >
    > > > Good luck
    > > >
    > > >
    > > >
    > > > "lula" wrote:
    > > >
    > > > > thank you for your help... I'm still trying to work it out. it still openning
    > > > > the same form even with that Dcount function... I'm sure that will work, but
    > > > > I must be putting something wrong... hahaa....
    > > > >
    > > > > still working....but thanks anyways...
    > > > >
    > > > > "Ofer" wrote:
    > > > >
    > > > > > Use the Dcount to see if there are any records in the table before you open
    > > > > > form2
    > > > > >
    > > > > > If Dcount("*", "TableName","[computer Field Name In the table] = '" & Me![
    > > > > > computer Field Name In the form] & "'") = 0 then
    > > > > > msgbox "No records for this computer"
    > > > > > else
    > > > > > docmd.openform "Form2"
    > > > > > End if
    > > > > > --
    > > > > > If I answered your question, please mark it as an answer. That way, it will
    > > > > > stay saved for a longer time, so other can benefit from it.
    > > > > >
    > > > > > Good luck
    > > > > >
    > > > > >
    > > > > >
    > > > > > "lula" wrote:
    > > > > >
    > > > > > > hi there... sorry... I'm very very new at access 2000 and I cannot figure out
    > > > > > > how I can do an if clause.
    > > > > > >
    > > > > > > this is what's going on... I have a form that shows information about
    > > > > > > computers (form1). I have another form (form2) that contains information
    > > > > > > about computer repair requests(CRR). I have a button on form1 that brings me
    > > > > > > the CRR for the computer that the form1 is showing at that moment. but what I
    > > > > > > need is that If there's no CRR for that computer, to display a message
    > > > > > > saying: no CRR for that computer....
    > > > > > >
    > > > > > > I wanted to do that with an if clause in the button properties, but I'm so
    > > > > > > dumb that I cannot figure it out.....
    > > > > > >
    > > > > > > can you help me please??? I'm sure that is going to be very easy for all of
    > > > > > > you
    > > > > > >
    > > > > > > thanks
     
  12. Ofer

    Ofer
    Expand Collapse
    Guest

    Sorry, it my mistake, try this
    Private Sub CmdOpenCRRFrm_Click()
    On Error GoTo Err_CmdOpenCRRFrm_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "CRRFiltered"

    stLinkCriteria = "[id_tag]=" & Me![id_tag]

    If DCount("*", "CRR", "[id_tag] = " & Me![id_tag]) = 0 Then
    MsgBox "No records for this computer"
    Else
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    End If

    Exit_CmdOpenCRRFrm_Click:
    Exit Sub

    Err_CmdOpenCRRFrm_Click:
    MsgBox Err.description
    Resume Exit_CmdOpenCRRFrm_Click

    End Sub

    --
    If I answered your question, please mark it as an answer. That way, it will
    stay saved for a longer time, so other can benefit from it.

    Good luck



    "lula" wrote:

    > hi again.... I copy that code and I have a message saying that "Data type
    > mismatch in criteria expression" and it's not openning any other form... do
    > you know what that can be about??
    >
    > thank you for your help again!
    >
    >
    >
    > "Ofer" wrote:
    >
    > > Try this
    > >
    > > Private Sub CmdOpenCRRFrm_Click()
    > > On Error GoTo Err_CmdOpenCRRFrm_Click
    > >
    > > Dim stDocName As String
    > > Dim stLinkCriteria As String
    > > stDocName = "CRRFiltered"
    > >
    > > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > >
    > > If DCount("*", "CRR", "[id_tag] = '" & Me![id_tag] & "'") = 0 Then
    > > MsgBox "No records for this computer"
    > > Else
    > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > > End If
    > >
    > > Exit_CmdOpenCRRFrm_Click:
    > > Exit Sub
    > >
    > > Err_CmdOpenCRRFrm_Click:
    > > MsgBox Err.description
    > > Resume Exit_CmdOpenCRRFrm_Click
    > >
    > > End Sub
    > >
    > > --
    > > If I answered your question, please mark it as an answer. That way, it will
    > > stay saved for a longer time, so other can benefit from it.
    > >
    > > Good luck
    > >
    > >
    > >
    > > "lula" wrote:
    > >
    > > > thank you.....
    > > >
    > > > this is the one I put in after your idea.....
    > > >
    > > >
    > > > Private Sub CmdOpenCRRFrm_Click()
    > > > On Error GoTo Err_CmdOpenCRRFrm_Click
    > > >
    > > > Dim stDocName As String
    > > > Dim stLinkCriteria As String
    > > > stDocName = "CRRFiltered"
    > > >
    > > > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > > >
    > > > If DCount("*", "CRR", "[id_tag] = '" & Me![id_tag] & "'") = 0 Then
    > > > MsgBox "No records for this computer"
    > > > Else
    > > > DoCmd.OpenForm "CRRFiltered"
    > > > End If
    > > >
    > > > Exit_CmdOpenCRRFrm_Click:
    > > > Exit Sub
    > > >
    > > > Err_CmdOpenCRRFrm_Click:
    > > > MsgBox Err.description
    > > > Resume Exit_CmdOpenCRRFrm_Click
    > > >
    > > > End Sub
    > > >
    > > > this is the one I had at the beginning showing the CRR even if it didn't
    > > > have any CRR attached to the computer.
    > > > Private Sub CmdOpenCRRFrm_Click()
    > > > On Error GoTo Err_CmdOpenCRRFrm_Click
    > > >
    > > > Dim stDocName As String
    > > > Dim stLinkCriteria As String
    > > > stDocName = "CRRFiltered"
    > > >
    > > > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > > >
    > > > Exit_CmdOpenCRRFrm_Click:
    > > > Exit Sub
    > > >
    > > > Err_CmdOpenCRRFrm_Click:
    > > > MsgBox Err.description
    > > > Resume Exit_CmdOpenCRRFrm_Click
    > > >
    > > > End Sub
    > > >
    > > >
    > > >
    > > >
    > > > "Ofer" wrote:
    > > >
    > > > > can you post your code, please?
    > > > > --
    > > > > If I answered your question, please mark it as an answer. That way, it will
    > > > > stay saved for a longer time, so other can benefit from it.
    > > > >
    > > > > Good luck
    > > > >
    > > > >
    > > > >
    > > > > "lula" wrote:
    > > > >
    > > > > > thank you for your help... I'm still trying to work it out. it still openning
    > > > > > the same form even with that Dcount function... I'm sure that will work, but
    > > > > > I must be putting something wrong... hahaa....
    > > > > >
    > > > > > still working....but thanks anyways...
    > > > > >
    > > > > > "Ofer" wrote:
    > > > > >
    > > > > > > Use the Dcount to see if there are any records in the table before you open
    > > > > > > form2
    > > > > > >
    > > > > > > If Dcount("*", "TableName","[computer Field Name In the table] = '" & Me![
    > > > > > > computer Field Name In the form] & "'") = 0 then
    > > > > > > msgbox "No records for this computer"
    > > > > > > else
    > > > > > > docmd.openform "Form2"
    > > > > > > End if
    > > > > > > --
    > > > > > > If I answered your question, please mark it as an answer. That way, it will
    > > > > > > stay saved for a longer time, so other can benefit from it.
    > > > > > >
    > > > > > > Good luck
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > > "lula" wrote:
    > > > > > >
    > > > > > > > hi there... sorry... I'm very very new at access 2000 and I cannot figure out
    > > > > > > > how I can do an if clause.
    > > > > > > >
    > > > > > > > this is what's going on... I have a form that shows information about
    > > > > > > > computers (form1). I have another form (form2) that contains information
    > > > > > > > about computer repair requests(CRR). I have a button on form1 that brings me
    > > > > > > > the CRR for the computer that the form1 is showing at that moment. but what I
    > > > > > > > need is that If there's no CRR for that computer, to display a message
    > > > > > > > saying: no CRR for that computer....
    > > > > > > >
    > > > > > > > I wanted to do that with an if clause in the button properties, but I'm so
    > > > > > > > dumb that I cannot figure it out.....
    > > > > > > >
    > > > > > > > can you help me please??? I'm sure that is going to be very easy for all of
    > > > > > > > you
    > > > > > > >
    > > > > > > > thanks
     
  13. lula

    lula
    Expand Collapse
    Guest

    hey... It worked perfectly!!!!! thank you so much! now I have to deal with
    some word document import thing... but at least this is done!!!!

    thank you again!

    "Ofer" wrote:

    > Sorry, it my mistake, try this
    > Private Sub CmdOpenCRRFrm_Click()
    > On Error GoTo Err_CmdOpenCRRFrm_Click
    >
    > Dim stDocName As String
    > Dim stLinkCriteria As String
    > stDocName = "CRRFiltered"
    >
    > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    >
    > If DCount("*", "CRR", "[id_tag] = " & Me![id_tag]) = 0 Then
    > MsgBox "No records for this computer"
    > Else
    > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > End If
    >
    > Exit_CmdOpenCRRFrm_Click:
    > Exit Sub
    >
    > Err_CmdOpenCRRFrm_Click:
    > MsgBox Err.description
    > Resume Exit_CmdOpenCRRFrm_Click
    >
    > End Sub
    >
    > --
    > If I answered your question, please mark it as an answer. That way, it will
    > stay saved for a longer time, so other can benefit from it.
    >
    > Good luck
    >
    >
    >
    > "lula" wrote:
    >
    > > hi again.... I copy that code and I have a message saying that "Data type
    > > mismatch in criteria expression" and it's not openning any other form... do
    > > you know what that can be about??
    > >
    > > thank you for your help again!
    > >
    > >
    > >
    > > "Ofer" wrote:
    > >
    > > > Try this
    > > >
    > > > Private Sub CmdOpenCRRFrm_Click()
    > > > On Error GoTo Err_CmdOpenCRRFrm_Click
    > > >
    > > > Dim stDocName As String
    > > > Dim stLinkCriteria As String
    > > > stDocName = "CRRFiltered"
    > > >
    > > > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > > >
    > > > If DCount("*", "CRR", "[id_tag] = '" & Me![id_tag] & "'") = 0 Then
    > > > MsgBox "No records for this computer"
    > > > Else
    > > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > > > End If
    > > >
    > > > Exit_CmdOpenCRRFrm_Click:
    > > > Exit Sub
    > > >
    > > > Err_CmdOpenCRRFrm_Click:
    > > > MsgBox Err.description
    > > > Resume Exit_CmdOpenCRRFrm_Click
    > > >
    > > > End Sub
    > > >
    > > > --
    > > > If I answered your question, please mark it as an answer. That way, it will
    > > > stay saved for a longer time, so other can benefit from it.
    > > >
    > > > Good luck
    > > >
    > > >
    > > >
    > > > "lula" wrote:
    > > >
    > > > > thank you.....
    > > > >
    > > > > this is the one I put in after your idea.....
    > > > >
    > > > >
    > > > > Private Sub CmdOpenCRRFrm_Click()
    > > > > On Error GoTo Err_CmdOpenCRRFrm_Click
    > > > >
    > > > > Dim stDocName As String
    > > > > Dim stLinkCriteria As String
    > > > > stDocName = "CRRFiltered"
    > > > >
    > > > > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > > > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > > > >
    > > > > If DCount("*", "CRR", "[id_tag] = '" & Me![id_tag] & "'") = 0 Then
    > > > > MsgBox "No records for this computer"
    > > > > Else
    > > > > DoCmd.OpenForm "CRRFiltered"
    > > > > End If
    > > > >
    > > > > Exit_CmdOpenCRRFrm_Click:
    > > > > Exit Sub
    > > > >
    > > > > Err_CmdOpenCRRFrm_Click:
    > > > > MsgBox Err.description
    > > > > Resume Exit_CmdOpenCRRFrm_Click
    > > > >
    > > > > End Sub
    > > > >
    > > > > this is the one I had at the beginning showing the CRR even if it didn't
    > > > > have any CRR attached to the computer.
    > > > > Private Sub CmdOpenCRRFrm_Click()
    > > > > On Error GoTo Err_CmdOpenCRRFrm_Click
    > > > >
    > > > > Dim stDocName As String
    > > > > Dim stLinkCriteria As String
    > > > > stDocName = "CRRFiltered"
    > > > >
    > > > > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > > > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > > > >
    > > > > Exit_CmdOpenCRRFrm_Click:
    > > > > Exit Sub
    > > > >
    > > > > Err_CmdOpenCRRFrm_Click:
    > > > > MsgBox Err.description
    > > > > Resume Exit_CmdOpenCRRFrm_Click
    > > > >
    > > > > End Sub
    > > > >
    > > > >
    > > > >
    > > > >
    > > > > "Ofer" wrote:
    > > > >
    > > > > > can you post your code, please?
    > > > > > --
    > > > > > If I answered your question, please mark it as an answer. That way, it will
    > > > > > stay saved for a longer time, so other can benefit from it.
    > > > > >
    > > > > > Good luck
    > > > > >
    > > > > >
    > > > > >
    > > > > > "lula" wrote:
    > > > > >
    > > > > > > thank you for your help... I'm still trying to work it out. it still openning
    > > > > > > the same form even with that Dcount function... I'm sure that will work, but
    > > > > > > I must be putting something wrong... hahaa....
    > > > > > >
    > > > > > > still working....but thanks anyways...
    > > > > > >
    > > > > > > "Ofer" wrote:
    > > > > > >
    > > > > > > > Use the Dcount to see if there are any records in the table before you open
    > > > > > > > form2
    > > > > > > >
    > > > > > > > If Dcount("*", "TableName","[computer Field Name In the table] = '" & Me![
    > > > > > > > computer Field Name In the form] & "'") = 0 then
    > > > > > > > msgbox "No records for this computer"
    > > > > > > > else
    > > > > > > > docmd.openform "Form2"
    > > > > > > > End if
    > > > > > > > --
    > > > > > > > If I answered your question, please mark it as an answer. That way, it will
    > > > > > > > stay saved for a longer time, so other can benefit from it.
    > > > > > > >
    > > > > > > > Good luck
    > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > > > "lula" wrote:
    > > > > > > >
    > > > > > > > > hi there... sorry... I'm very very new at access 2000 and I cannot figure out
    > > > > > > > > how I can do an if clause.
    > > > > > > > >
    > > > > > > > > this is what's going on... I have a form that shows information about
    > > > > > > > > computers (form1). I have another form (form2) that contains information
    > > > > > > > > about computer repair requests(CRR). I have a button on form1 that brings me
    > > > > > > > > the CRR for the computer that the form1 is showing at that moment. but what I
    > > > > > > > > need is that If there's no CRR for that computer, to display a message
    > > > > > > > > saying: no CRR for that computer....
    > > > > > > > >
    > > > > > > > > I wanted to do that with an if clause in the button properties, but I'm so
    > > > > > > > > dumb that I cannot figure it out.....
    > > > > > > > >
    > > > > > > > > can you help me please??? I'm sure that is going to be very easy for all of
    > > > > > > > > you
    > > > > > > > >
    > > > > > > > > thanks
     
  14. Ofer

    Ofer
    Expand Collapse
    Guest

    You very welcome :)
    --
    If I answered your question, please mark it as an answer. That way, it will
    stay saved for a longer time, so other can benefit from it.

    Good luck



    "lula" wrote:

    > hey... It worked perfectly!!!!! thank you so much! now I have to deal with
    > some word document import thing... but at least this is done!!!!
    >
    > thank you again!
    >
    > "Ofer" wrote:
    >
    > > Sorry, it my mistake, try this
    > > Private Sub CmdOpenCRRFrm_Click()
    > > On Error GoTo Err_CmdOpenCRRFrm_Click
    > >
    > > Dim stDocName As String
    > > Dim stLinkCriteria As String
    > > stDocName = "CRRFiltered"
    > >
    > > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > >
    > > If DCount("*", "CRR", "[id_tag] = " & Me![id_tag]) = 0 Then
    > > MsgBox "No records for this computer"
    > > Else
    > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > > End If
    > >
    > > Exit_CmdOpenCRRFrm_Click:
    > > Exit Sub
    > >
    > > Err_CmdOpenCRRFrm_Click:
    > > MsgBox Err.description
    > > Resume Exit_CmdOpenCRRFrm_Click
    > >
    > > End Sub
    > >
    > > --
    > > If I answered your question, please mark it as an answer. That way, it will
    > > stay saved for a longer time, so other can benefit from it.
    > >
    > > Good luck
    > >
    > >
    > >
    > > "lula" wrote:
    > >
    > > > hi again.... I copy that code and I have a message saying that "Data type
    > > > mismatch in criteria expression" and it's not openning any other form... do
    > > > you know what that can be about??
    > > >
    > > > thank you for your help again!
    > > >
    > > >
    > > >
    > > > "Ofer" wrote:
    > > >
    > > > > Try this
    > > > >
    > > > > Private Sub CmdOpenCRRFrm_Click()
    > > > > On Error GoTo Err_CmdOpenCRRFrm_Click
    > > > >
    > > > > Dim stDocName As String
    > > > > Dim stLinkCriteria As String
    > > > > stDocName = "CRRFiltered"
    > > > >
    > > > > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > > > >
    > > > > If DCount("*", "CRR", "[id_tag] = '" & Me![id_tag] & "'") = 0 Then
    > > > > MsgBox "No records for this computer"
    > > > > Else
    > > > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > > > > End If
    > > > >
    > > > > Exit_CmdOpenCRRFrm_Click:
    > > > > Exit Sub
    > > > >
    > > > > Err_CmdOpenCRRFrm_Click:
    > > > > MsgBox Err.description
    > > > > Resume Exit_CmdOpenCRRFrm_Click
    > > > >
    > > > > End Sub
    > > > >
    > > > > --
    > > > > If I answered your question, please mark it as an answer. That way, it will
    > > > > stay saved for a longer time, so other can benefit from it.
    > > > >
    > > > > Good luck
    > > > >
    > > > >
    > > > >
    > > > > "lula" wrote:
    > > > >
    > > > > > thank you.....
    > > > > >
    > > > > > this is the one I put in after your idea.....
    > > > > >
    > > > > >
    > > > > > Private Sub CmdOpenCRRFrm_Click()
    > > > > > On Error GoTo Err_CmdOpenCRRFrm_Click
    > > > > >
    > > > > > Dim stDocName As String
    > > > > > Dim stLinkCriteria As String
    > > > > > stDocName = "CRRFiltered"
    > > > > >
    > > > > > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > > > > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > > > > >
    > > > > > If DCount("*", "CRR", "[id_tag] = '" & Me![id_tag] & "'") = 0 Then
    > > > > > MsgBox "No records for this computer"
    > > > > > Else
    > > > > > DoCmd.OpenForm "CRRFiltered"
    > > > > > End If
    > > > > >
    > > > > > Exit_CmdOpenCRRFrm_Click:
    > > > > > Exit Sub
    > > > > >
    > > > > > Err_CmdOpenCRRFrm_Click:
    > > > > > MsgBox Err.description
    > > > > > Resume Exit_CmdOpenCRRFrm_Click
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > > this is the one I had at the beginning showing the CRR even if it didn't
    > > > > > have any CRR attached to the computer.
    > > > > > Private Sub CmdOpenCRRFrm_Click()
    > > > > > On Error GoTo Err_CmdOpenCRRFrm_Click
    > > > > >
    > > > > > Dim stDocName As String
    > > > > > Dim stLinkCriteria As String
    > > > > > stDocName = "CRRFiltered"
    > > > > >
    > > > > > stLinkCriteria = "[id_tag]=" & Me![id_tag]
    > > > > > DoCmd.OpenForm stDocName, , , stLinkCriteria
    > > > > >
    > > > > > Exit_CmdOpenCRRFrm_Click:
    > > > > > Exit Sub
    > > > > >
    > > > > > Err_CmdOpenCRRFrm_Click:
    > > > > > MsgBox Err.description
    > > > > > Resume Exit_CmdOpenCRRFrm_Click
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > > "Ofer" wrote:
    > > > > >
    > > > > > > can you post your code, please?
    > > > > > > --
    > > > > > > If I answered your question, please mark it as an answer. That way, it will
    > > > > > > stay saved for a longer time, so other can benefit from it.
    > > > > > >
    > > > > > > Good luck
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > > "lula" wrote:
    > > > > > >
    > > > > > > > thank you for your help... I'm still trying to work it out. it still openning
    > > > > > > > the same form even with that Dcount function... I'm sure that will work, but
    > > > > > > > I must be putting something wrong... hahaa....
    > > > > > > >
    > > > > > > > still working....but thanks anyways...
    > > > > > > >
    > > > > > > > "Ofer" wrote:
    > > > > > > >
    > > > > > > > > Use the Dcount to see if there are any records in the table before you open
    > > > > > > > > form2
    > > > > > > > >
    > > > > > > > > If Dcount("*", "TableName","[computer Field Name In the table] = '" & Me![
    > > > > > > > > computer Field Name In the form] & "'") = 0 then
    > > > > > > > > msgbox "No records for this computer"
    > > > > > > > > else
    > > > > > > > > docmd.openform "Form2"
    > > > > > > > > End if
    > > > > > > > > --
    > > > > > > > > If I answered your question, please mark it as an answer. That way, it will
    > > > > > > > > stay saved for a longer time, so other can benefit from it.
    > > > > > > > >
    > > > > > > > > Good luck
    > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > "lula" wrote:
    > > > > > > > >
    > > > > > > > > > hi there... sorry... I'm very very new at access 2000 and I cannot figure out
    > > > > > > > > > how I can do an if clause.
    > > > > > > > > >
    > > > > > > > > > this is what's going on... I have a form that shows information about
    > > > > > > > > > computers (form1). I have another form (form2) that contains information
    > > > > > > > > > about computer repair requests(CRR). I have a button on form1 that brings me
    > > > > > > > > > the CRR for the computer that the form1 is showing at that moment. but what I
    > > > > > > > > > need is that If there's no CRR for that computer, to display a message
    > > > > > > > > > saying: no CRR for that computer....
    > > > > > > > > >
    > > > > > > > > > I wanted to do that with an if clause in the button properties, but I'm so
    > > > > > > > > > dumb that I cannot figure it out.....
    > > > > > > > > >
    > > > > > > > > > can you help me please??? I'm sure that is going to be very easy for all of
    > > > > > > > > > you
    > > > > > > > > >
    > > > > > > > > > thanks
     

Share This Page