dlookup

T

tmaxwell

I need to write a query to link a number of table together so I can build a
form page that the project managers can type in a part number and retrieve
all the specs of the part. Can I use the dlookup to do this?
 
O

Ofer Cohen

Don't use DLookup for that,

Create a form based on the query you created, and then add another search
text box where the user can input value and all the related field will pear.

Check this link on "Searching for a record based on a text box value in a
form:"

http://www.databasedev.co.uk/text_search.html
 
T

tmaxwell

I am trying to use a cmdSearch command button. I have a query that I built
the form page from and I need the ability to type in a part number and have
the cmdSearch find the record. The query is named PARTSEARCH and the part
field is 2nditemnum as MODEL. Please take a look and let me know why this
won’t run. I can give more detail.



Option Compare Database


Private Sub cmdSearch_Click()
Dim strPARTSEARCHRef As String
Dim strSearch As String

'Check txtSearch for Null value or Nill Entry first.

If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criteria!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------

'Performs the search using value entered into txtSearch

DoCmd.ShowAllRecords
DoCmd.GoToControl ("2NDITEMNUM AS MODEL")
DoCmd.FindRecord Me!txtSearch

str2NDITEMNUM AS MODEL.SetFocus
strPARTSEARCHRef = str2NDITEMNUM AS MODEL.Text
txtSearch.SetFocus
strSearch = txtSearch.Text

'If matching record found sets focus in and shows msgbox
'and clears search control

If strSEARCHRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congratulations!"
str2NDITEMNUM As MODEL.SetFocus
txtSearch = ""

'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
txtSearch.SetFocus
End If
End Sub


Private Sub txtSearch_BeforeUpdate(Cancel As Integer)

End Sub
 
O

Ofer Cohen

What error do you get?

Also, when you have a name of a control , field, table that consist more the
one word it need to be in square brackets

DoCmd.GoToControl ("[2NDITEMNUM AS MODEL]")

Is that "[2NDITEMNUM AS MODEL]" the text box name?

Note: It's not recomnded to give names to the controls when they consist
more then one word.

You can write it as, so it will be connected
2NDITEMNUM_AS_MODEL
--
Good Luck
BS"D


tmaxwell said:
I am trying to use a cmdSearch command button. I have a query that I built
the form page from and I need the ability to type in a part number and have
the cmdSearch find the record. The query is named PARTSEARCH and the part
field is 2nditemnum as MODEL. Please take a look and let me know why this
won’t run. I can give more detail.



Option Compare Database


Private Sub cmdSearch_Click()
Dim strPARTSEARCHRef As String
Dim strSearch As String

'Check txtSearch for Null value or Nill Entry first.

If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criteria!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------

'Performs the search using value entered into txtSearch

DoCmd.ShowAllRecords
DoCmd.GoToControl ("2NDITEMNUM AS MODEL")
DoCmd.FindRecord Me!txtSearch

str2NDITEMNUM AS MODEL.SetFocus
strPARTSEARCHRef = str2NDITEMNUM AS MODEL.Text
txtSearch.SetFocus
strSearch = txtSearch.Text

'If matching record found sets focus in and shows msgbox
'and clears search control

If strSEARCHRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congratulations!"
str2NDITEMNUM As MODEL.SetFocus
txtSearch = ""

'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
txtSearch.SetFocus
End If
End Sub


Private Sub txtSearch_BeforeUpdate(Cancel As Integer)

End Sub


Ofer Cohen said:
Don't use DLookup for that,

Create a form based on the query you created, and then add another search
text box where the user can input value and all the related field will pear.

Check this link on "Searching for a record based on a text box value in a
form:"

http://www.databasedev.co.uk/text_search.html
 
T

tmaxwell

The error is "There is no field named 2NDITEMNUM AS MODEL in the current
record"

[Daily Sales].[2NDITEMNUM] AS MODEL so I have named it 2NDITEMNUM as MODEL






Ofer Cohen said:
What error do you get?

Also, when you have a name of a control , field, table that consist more the
one word it need to be in square brackets

DoCmd.GoToControl ("[2NDITEMNUM AS MODEL]")

Is that "[2NDITEMNUM AS MODEL]" the text box name?

Note: It's not recomnded to give names to the controls when they consist
more then one word.

You can write it as, so it will be connected
2NDITEMNUM_AS_MODEL
--
Good Luck
BS"D


tmaxwell said:
I am trying to use a cmdSearch command button. I have a query that I built
the form page from and I need the ability to type in a part number and have
the cmdSearch find the record. The query is named PARTSEARCH and the part
field is 2nditemnum as MODEL. Please take a look and let me know why this
won’t run. I can give more detail.



Option Compare Database


Private Sub cmdSearch_Click()
Dim strPARTSEARCHRef As String
Dim strSearch As String

'Check txtSearch for Null value or Nill Entry first.

If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criteria!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------

'Performs the search using value entered into txtSearch

DoCmd.ShowAllRecords
DoCmd.GoToControl ("2NDITEMNUM AS MODEL")
DoCmd.FindRecord Me!txtSearch

str2NDITEMNUM AS MODEL.SetFocus
strPARTSEARCHRef = str2NDITEMNUM AS MODEL.Text
txtSearch.SetFocus
strSearch = txtSearch.Text

'If matching record found sets focus in and shows msgbox
'and clears search control

If strSEARCHRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congratulations!"
str2NDITEMNUM As MODEL.SetFocus
txtSearch = ""

'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
txtSearch.SetFocus
End If
End Sub


Private Sub txtSearch_BeforeUpdate(Cancel As Integer)

End Sub


Ofer Cohen said:
Don't use DLookup for that,

Create a form based on the query you created, and then add another search
text box where the user can input value and all the related field will pear.

Check this link on "Searching for a record based on a text box value in a
form:"

http://www.databasedev.co.uk/text_search.html

--
Good Luck
BS"D


:

I need to write a query to link a number of table together so I can build a
form page that the project managers can type in a part number and retrieve
all the specs of the part. Can I use the dlookup to do this?
 
O

Ofer Cohen

If the field name MODEL then try

DoCmd.GoToControl ("MODEL")

--
Good Luck
BS"D


tmaxwell said:
The error is "There is no field named 2NDITEMNUM AS MODEL in the current
record"

[Daily Sales].[2NDITEMNUM] AS MODEL so I have named it 2NDITEMNUM as MODEL






Ofer Cohen said:
What error do you get?

Also, when you have a name of a control , field, table that consist more the
one word it need to be in square brackets

DoCmd.GoToControl ("[2NDITEMNUM AS MODEL]")

Is that "[2NDITEMNUM AS MODEL]" the text box name?

Note: It's not recomnded to give names to the controls when they consist
more then one word.

You can write it as, so it will be connected
2NDITEMNUM_AS_MODEL
--
Good Luck
BS"D


tmaxwell said:
I am trying to use a cmdSearch command button. I have a query that I built
the form page from and I need the ability to type in a part number and have
the cmdSearch find the record. The query is named PARTSEARCH and the part
field is 2nditemnum as MODEL. Please take a look and let me know why this
won’t run. I can give more detail.



Option Compare Database


Private Sub cmdSearch_Click()
Dim strPARTSEARCHRef As String
Dim strSearch As String

'Check txtSearch for Null value or Nill Entry first.

If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criteria!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------

'Performs the search using value entered into txtSearch

DoCmd.ShowAllRecords
DoCmd.GoToControl ("2NDITEMNUM AS MODEL")
DoCmd.FindRecord Me!txtSearch

str2NDITEMNUM AS MODEL.SetFocus
strPARTSEARCHRef = str2NDITEMNUM AS MODEL.Text
txtSearch.SetFocus
strSearch = txtSearch.Text

'If matching record found sets focus in and shows msgbox
'and clears search control

If strSEARCHRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congratulations!"
str2NDITEMNUM As MODEL.SetFocus
txtSearch = ""

'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
txtSearch.SetFocus
End If
End Sub


Private Sub txtSearch_BeforeUpdate(Cancel As Integer)

End Sub


:

Don't use DLookup for that,

Create a form based on the query you created, and then add another search
text box where the user can input value and all the related field will pear.

Check this link on "Searching for a record based on a text box value in a
form:"

http://www.databasedev.co.uk/text_search.html

--
Good Luck
BS"D


:

I need to write a query to link a number of table together so I can build a
form page that the project managers can type in a part number and retrieve
all the specs of the part. Can I use the dlookup to do this?
 
T

tmaxwell

It works right through the DoCmd.GoToControl ("MODEL") but hangs at the
DoCmd.FindRecord Me!txtSearch . Do I need to add the FindFirst option?

Private Sub cmdsearch_Click()
Dim strPARTSRef As String
Dim strSearch As String


If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------


DoCmd.ShowAllRecords
DoCmd.GoToControl ("MODEL")
DoCmd.FindRecord Me!txtSearch

strMODEL.SetFocus
strPARTSRef = strMODEL.Text
txtSearch.SetFocus
strSearch = txtSearch.Text



If strPARTSRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congrats!"
strMODEL.SetFocus
txtSearch = ""


Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
txtSearch.SetFocus
End If
End Sub









Ofer Cohen said:
If the field name MODEL then try

DoCmd.GoToControl ("MODEL")

--
Good Luck
BS"D


tmaxwell said:
The error is "There is no field named 2NDITEMNUM AS MODEL in the current
record"

[Daily Sales].[2NDITEMNUM] AS MODEL so I have named it 2NDITEMNUM as MODEL






Ofer Cohen said:
What error do you get?

Also, when you have a name of a control , field, table that consist more the
one word it need to be in square brackets

DoCmd.GoToControl ("[2NDITEMNUM AS MODEL]")

Is that "[2NDITEMNUM AS MODEL]" the text box name?

Note: It's not recomnded to give names to the controls when they consist
more then one word.

You can write it as, so it will be connected
2NDITEMNUM_AS_MODEL
--
Good Luck
BS"D


:

I am trying to use a cmdSearch command button. I have a query that I built
the form page from and I need the ability to type in a part number and have
the cmdSearch find the record. The query is named PARTSEARCH and the part
field is 2nditemnum as MODEL. Please take a look and let me know why this
won’t run. I can give more detail.



Option Compare Database


Private Sub cmdSearch_Click()
Dim strPARTSEARCHRef As String
Dim strSearch As String

'Check txtSearch for Null value or Nill Entry first.

If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criteria!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------

'Performs the search using value entered into txtSearch

DoCmd.ShowAllRecords
DoCmd.GoToControl ("2NDITEMNUM AS MODEL")
DoCmd.FindRecord Me!txtSearch

str2NDITEMNUM AS MODEL.SetFocus
strPARTSEARCHRef = str2NDITEMNUM AS MODEL.Text
txtSearch.SetFocus
strSearch = txtSearch.Text

'If matching record found sets focus in and shows msgbox
'and clears search control

If strSEARCHRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congratulations!"
str2NDITEMNUM As MODEL.SetFocus
txtSearch = ""

'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
txtSearch.SetFocus
End If
End Sub


Private Sub txtSearch_BeforeUpdate(Cancel As Integer)

End Sub


:

Don't use DLookup for that,

Create a form based on the query you created, and then add another search
text box where the user can input value and all the related field will pear.

Check this link on "Searching for a record based on a text box value in a
form:"

http://www.databasedev.co.uk/text_search.html

--
Good Luck
BS"D


:

I need to write a query to link a number of table together so I can build a
form page that the project managers can type in a part number and retrieve
all the specs of the part. Can I use the dlookup to do this?
 
O

Ofer Cohen

Can you post your mdb to
chamudim <@> hotmail <.> com

I'll would like to have a look at it.
If you don't mind sending it, then zip it first because hotmail has issues
with mdb's


--
Good Luck
BS"D


tmaxwell said:
It works right through the DoCmd.GoToControl ("MODEL") but hangs at the
DoCmd.FindRecord Me!txtSearch . Do I need to add the FindFirst option?

Private Sub cmdsearch_Click()
Dim strPARTSRef As String
Dim strSearch As String


If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criterion!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------


DoCmd.ShowAllRecords
DoCmd.GoToControl ("MODEL")
DoCmd.FindRecord Me!txtSearch

strMODEL.SetFocus
strPARTSRef = strMODEL.Text
txtSearch.SetFocus
strSearch = txtSearch.Text



If strPARTSRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congrats!"
strMODEL.SetFocus
txtSearch = ""


Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
txtSearch.SetFocus
End If
End Sub









Ofer Cohen said:
If the field name MODEL then try

DoCmd.GoToControl ("MODEL")

--
Good Luck
BS"D


tmaxwell said:
The error is "There is no field named 2NDITEMNUM AS MODEL in the current
record"

[Daily Sales].[2NDITEMNUM] AS MODEL so I have named it 2NDITEMNUM as MODEL






:

What error do you get?

Also, when you have a name of a control , field, table that consist more the
one word it need to be in square brackets

DoCmd.GoToControl ("[2NDITEMNUM AS MODEL]")

Is that "[2NDITEMNUM AS MODEL]" the text box name?

Note: It's not recomnded to give names to the controls when they consist
more then one word.

You can write it as, so it will be connected
2NDITEMNUM_AS_MODEL
--
Good Luck
BS"D


:

I am trying to use a cmdSearch command button. I have a query that I built
the form page from and I need the ability to type in a part number and have
the cmdSearch find the record. The query is named PARTSEARCH and the part
field is 2nditemnum as MODEL. Please take a look and let me know why this
won’t run. I can give more detail.



Option Compare Database


Private Sub cmdSearch_Click()
Dim strPARTSEARCHRef As String
Dim strSearch As String

'Check txtSearch for Null value or Nill Entry first.

If IsNull(Me![txtSearch]) Or (Me![txtSearch]) = "" Then
MsgBox "Please enter a value!", vbOKOnly, "Invalid Search Criteria!"
Me![txtSearch].SetFocus
Exit Sub
End If
'---------------------------------------------------------------

'Performs the search using value entered into txtSearch

DoCmd.ShowAllRecords
DoCmd.GoToControl ("2NDITEMNUM AS MODEL")
DoCmd.FindRecord Me!txtSearch

str2NDITEMNUM AS MODEL.SetFocus
strPARTSEARCHRef = str2NDITEMNUM AS MODEL.Text
txtSearch.SetFocus
strSearch = txtSearch.Text

'If matching record found sets focus in and shows msgbox
'and clears search control

If strSEARCHRef = strSearch Then
MsgBox "Match Found For: " & strSearch, , "Congratulations!"
str2NDITEMNUM As MODEL.SetFocus
txtSearch = ""

'If value not found sets focus back to txtSearch and shows msgbox
Else
MsgBox "Match Not Found For: " & strSearch & " - Please Try
Again.", _
, "Invalid Search Criterion!"
txtSearch.SetFocus
End If
End Sub


Private Sub txtSearch_BeforeUpdate(Cancel As Integer)

End Sub


:

Don't use DLookup for that,

Create a form based on the query you created, and then add another search
text box where the user can input value and all the related field will pear.

Check this link on "Searching for a record based on a text box value in a
form:"

http://www.databasedev.co.uk/text_search.html

--
Good Luck
BS"D


:

I need to write a query to link a number of table together so I can build a
form page that the project managers can type in a part number and retrieve
all the specs of the part. Can I use the dlookup to do this?
 
Top