Looking for data in filed

J

Jon

Greeting,
I have a form using as search form. In this form there is a txt box for
input a data(Numbers) and there is cmd button for open other form the display
result. I have made this code put does not work:

Private Sub Command66_Click()
On Error GoTo Err_Command66_Click
Dim stDocName As String
Dim stLinkCriteria As String
If Me.Text64 <> "[CONTRACT NO]=" = True Then
MsgBox "No Contract No. Found. Please input valid No.", vbCritical,
"No Data Found..."
Me.Text64.SetFocus
ElseIf Len(Me.Text64 & "") > 0 = True Then
stDocName = "Dispaly sorted reprot by Contract NO"
stLinkCriteria = "[CONTRACT NO]=" & Me![Text64]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "You Must Input a Contract No. First.", vbCritical, "No
Processor Selected..."
Me.Text64.SetFocus
End If
Exit Sub
Exit_Command66_Click:
Exit Sub
Err_Command66_Click:
MsgBox Err.Description
Resume Exit_Command66_Click
End Sub

- the text64 is for inputting a data(numbers)
- [contract No] is a filed in tbl called “ Contractorâ€
what I want to do is as follows:
-checking the text64 value if it empty, If true msgbox appears and request
inputting numbers as a bove
-checking the text64 value if it is not matching the data in the tbl. If
true , msgbox appears and telling that no record was found.

Any help plzzzz
 
J

Jeanette Cunningham

Hi Jon,
there is a problem with the line
If Me.Text64 <> "[CONTRACT NO]=" = True Then

I assume CONTRACT NO is a field in your form's record source.

I would code it a bit differently:

If Me.Text64 <> Me![CONTRACT NO] then

try this and see if it helps.

Jeanette Cunningham
 
J

Jon

hi Jeanette,
still as it is, there is a msgbox telling"Microsoft Access con not find
filed 'Contract No' referrred to in your experssion
by the way, Contract No is a field in table and query also, I want access to
look for the value in the table and if it is there , it is ok and show,
elase, msgbox will appears and tell there is no data found .
thansk

Jeanette Cunningham said:
Hi Jon,
there is a problem with the line
If Me.Text64 <> "[CONTRACT NO]=" = True Then

I assume CONTRACT NO is a field in your form's record source.

I would code it a bit differently:

If Me.Text64 <> Me![CONTRACT NO] then

try this and see if it helps.

Jeanette Cunningham

Jon said:
Greeting,
I have a form using as search form. In this form there is a txt box for
input a data(Numbers) and there is cmd button for open other form the
display
result. I have made this code put does not work:

Private Sub Command66_Click()
On Error GoTo Err_Command66_Click
Dim stDocName As String
Dim stLinkCriteria As String

If Me.Text64 <> "[CONTRACT NO]=" = True Then

MsgBox "No Contract No. Found. Please input valid No.", vbCritical,
"No Data Found..."
Me.Text64.SetFocus
ElseIf Len(Me.Text64 & "") > 0 = True Then
stDocName = "Dispaly sorted reprot by Contract NO"

stLinkCriteria = "[CONTRACT NO]=" & Me![Text64]

DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "You Must Input a Contract No. First.", vbCritical, "No
Processor Selected..."
Me.Text64.SetFocus
End If
Exit Sub
Exit_Command66_Click:
Exit Sub
Err_Command66_Click:
MsgBox Err.Description
Resume Exit_Command66_Click
End Sub

- the text64 is for inputting a data(numbers)
- [contract No] is a filed in tbl called " Contractor"
what I want to do is as follows:
-checking the text64 value if it empty, If true msgbox appears and request
inputting numbers as a bove
-checking the text64 value if it is not matching the data in the tbl. If
true , msgbox appears and telling that no record was found.

Any help plzzzz
 
J

Jeanette Cunningham

Hi Jon,

Try this:
Put the field Contract No as a textbox on your form
Name the textbox txtContractNo
You can set its visible property to no

Now we can do some checking in the code.

Immediately before the line:
If Me.Text64 <> "[CONTRACT NO]=" = True Then

type the following:
debug.print "contract no: " & me.txtContract No

this will tell us what access finds when it looks in the textbox for
txtContractNo

Now you can run the code in your form in the usual way, after the message
box with the error appears, close the form.
Go Ctl + G to make Access open the immediate window.
Now we can see the value of Contract No

If you see contract no:
then we know that the field contract no is null

If you see contract no: 158 or any other text or number after contract no:
then we know Access can find the Contract No
and we can move on to finding another reason for that error message popping
up.

Jeanette Cunningham

Jon said:
hi Jeanette,
still as it is, there is a msgbox telling"Microsoft Access con not find
filed 'Contract No' referrred to in your experssion
by the way, Contract No is a field in table and query also, I want access
to
look for the value in the table and if it is there , it is ok and show,
elase, msgbox will appears and tell there is no data found .
thansk

Jeanette Cunningham said:
Hi Jon,
there is a problem with the line
If Me.Text64 <> "[CONTRACT NO]=" = True Then

I assume CONTRACT NO is a field in your form's record source.

I would code it a bit differently:

If Me.Text64 <> Me![CONTRACT NO] then

try this and see if it helps.

Jeanette Cunningham

Jon said:
Greeting,
I have a form using as search form. In this form there is a txt box for
input a data(Numbers) and there is cmd button for open other form the
display
result. I have made this code put does not work:

Private Sub Command66_Click()
On Error GoTo Err_Command66_Click
Dim stDocName As String
Dim stLinkCriteria As String

If Me.Text64 <> "[CONTRACT NO]=" = True Then

MsgBox "No Contract No. Found. Please input valid No.",
vbCritical,
"No Data Found..."
Me.Text64.SetFocus
ElseIf Len(Me.Text64 & "") > 0 = True Then
stDocName = "Dispaly sorted reprot by Contract NO"

stLinkCriteria = "[CONTRACT NO]=" & Me![Text64]

DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "You Must Input a Contract No. First.", vbCritical, "No
Processor Selected..."
Me.Text64.SetFocus
End If
Exit Sub
Exit_Command66_Click:
Exit Sub
Err_Command66_Click:
MsgBox Err.Description
Resume Exit_Command66_Click
End Sub

- the text64 is for inputting a data(numbers)
- [contract No] is a filed in tbl called " Contractor"
what I want to do is as follows:
-checking the text64 value if it empty, If true msgbox appears and
request
inputting numbers as a bove
-checking the text64 value if it is not matching the data in the tbl.
If
true , msgbox appears and telling that no record was found.

Any help plzzzz
 
J

Jeanette Cunningham

Hi Jon,
this is a correction to my previous post

where I say

type the following:
debug.print "contract no: " & me.txtContract No

the bit
me.txtContract No
has a mistake in it
the mistake is the space between the t and the N

this should be typed as

debug.print "contract no: " & me.txtContractNo

Jeanette Cunningham




Jeanette Cunningham said:
Hi Jon,

Try this:
Put the field Contract No as a textbox on your form
Name the textbox txtContractNo
You can set its visible property to no

Now we can do some checking in the code.

Immediately before the line:
If Me.Text64 <> "[CONTRACT NO]=" = True Then

type the following:
debug.print "contract no: " & me.txtContract No

this will tell us what access finds when it looks in the textbox for
txtContractNo

Now you can run the code in your form in the usual way, after the message
box with the error appears, close the form.
Go Ctl + G to make Access open the immediate window.
Now we can see the value of Contract No

If you see contract no:
then we know that the field contract no is null

If you see contract no: 158 or any other text or number after contract
no: then we know Access can find the Contract No
and we can move on to finding another reason for that error message
popping up.

Jeanette Cunningham

Jon said:
hi Jeanette,
still as it is, there is a msgbox telling"Microsoft Access con not find
filed 'Contract No' referrred to in your experssion
by the way, Contract No is a field in table and query also, I want access
to
look for the value in the table and if it is there , it is ok and show,
elase, msgbox will appears and tell there is no data found .
thansk

Jeanette Cunningham said:
Hi Jon,
there is a problem with the line
If Me.Text64 <> "[CONTRACT NO]=" = True Then

I assume CONTRACT NO is a field in your form's record source.

I would code it a bit differently:

If Me.Text64 <> Me![CONTRACT NO] then

try this and see if it helps.

Jeanette Cunningham

Greeting,
I have a form using as search form. In this form there is a txt box
for
input a data(Numbers) and there is cmd button for open other form the
display
result. I have made this code put does not work:

Private Sub Command66_Click()
On Error GoTo Err_Command66_Click
Dim stDocName As String
Dim stLinkCriteria As String


If Me.Text64 <> "[CONTRACT NO]=" = True Then


MsgBox "No Contract No. Found. Please input valid No.",
vbCritical,
"No Data Found..."
Me.Text64.SetFocus
ElseIf Len(Me.Text64 & "") > 0 = True Then
stDocName = "Dispaly sorted reprot by Contract NO"


stLinkCriteria = "[CONTRACT NO]=" & Me![Text64]


DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "You Must Input a Contract No. First.", vbCritical, "No
Processor Selected..."
Me.Text64.SetFocus
End If
Exit Sub
Exit_Command66_Click:
Exit Sub
Err_Command66_Click:
MsgBox Err.Description
Resume Exit_Command66_Click
End Sub

- the text64 is for inputting a data(numbers)
- [contract No] is a filed in tbl called " Contractor"
what I want to do is as follows:
-checking the text64 value if it empty, If true msgbox appears and
request
inputting numbers as a bove
-checking the text64 value if it is not matching the data in the tbl.
If
true , msgbox appears and telling that no record was found.

Any help plzzzz
 

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

Similar Threads


Top