DlookUP...Dcount...

P

Peter

Hi all..i am really stucked with this, too most of you a very simple, issue…

In form A I have a text field (search field) and a command button..

On the “Click†event of the command button I want to find related data in a
table and IF the data exists..i want to open Form B with this data…IF not I
want to create a msgbox or open “DoCmd.Open†an additional form that prompts
me for further action…

1. Do I use a Dlookup for the table or ?

Private Sub Command35_Click()

stDocName = “Fruitsâ€

If DCount("*", "Fruits", "[Apples] ='" & Me.Fruits & "'") > 0 Then
DoCmd. OpenForm. stDocname,,,

And then my brain crashes……

Thanks!
 
A

anlu

Hi Peter,

Your question is how you filters your second form so that it displays only
that data entered on the first, right?

Try this (assuming the name of your second form is "Fruits"):
---------- code start -----------------
stDocName = “Fruitsâ€

If DCount("*", "Fruits", "[Apples] ='" & Me.Fruits & "'") > 0 Then
DoCmd.OpenForm stDocname
Forms!Fruits.Filter = "[Apples] ='" & Me.Fruits & "'"
Forms!Fruits.FilterOn = True
end if
---------- code end -----------------

Hope this helps you.
anlu
 
P

Peter

anlu said:
Hi Peter,

Your question is how you filters your second form so that it displays only
that data entered on the first, right?

Try this (assuming the name of your second form is "Fruits"):
---------- code start -----------------
stDocName = “Fruitsâ€

If DCount("*", "Fruits", "[Apples] ='" & Me.Fruits & "'") > 0 Then
DoCmd.OpenForm stDocname
Forms!Fruits.Filter = "[Apples] ='" & Me.Fruits & "'"
Forms!Fruits.FilterOn = True
end if
---------- code end -----------------

Hope this helps you.
anlu

Ok..i get it..i need to filter the records in that table, and then it
continuous


If DCount("*", "Fruits", "[Apples] ='" & Me.Fruits & "'") > 0 Then
DoCmd.OpenForm stDocname
Forms!Fruits.Filter = "[Apples] ='" & Me.Fruits & "'"
Forms!Fruits.FilterOn = True
Else

Msgbox “No apples of that type foundâ€

End if

Thanks a million times anlu…I am afraid I am stone dump when it comes to
this..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

Top