if clause in access 2000

  • Thread starter Thread starter Guest
  • Start date Start date
G

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
 
If you do not want to open the Form2 when no CRR exists then I would
suggest a DLookup() or DCount() before OpenForm command.

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.
 
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
 
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!
 
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 said:
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 said:
If you do not want to open the Form2 when no CRR exists then I would
suggest a DLookup() or DCount() before OpenForm command.


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
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 said:
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 said:
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
 
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 said:
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 said:
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 said:
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
 
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 said:
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 said:
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 said:
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



:

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
 
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 said:
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 said:
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 said:
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...

:

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



:

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
 
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 said:
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 said:
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 said:
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



:

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...

:

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



:

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
 
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 said:
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 said:
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 said:
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




:

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



:

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...

:

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



:

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
 
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 said:
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 said:
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 said:
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



:

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




:

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



:

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...

:

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



:

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
 
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 said:
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 said:
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 said:
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!



:

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



:

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




:

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



:

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...

:

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



:

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top