Heelp Needed in Access Please...!!!

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

Guest

Hello every body,
I am making a DB in access. I have a table which contains fields given below
: -
1. Name
2. ID number
3. Gender
4. City
5. file no
6. Company Name
7. Address.

I am ok with this table and my table is working properly. Now i want to make
a Form that has to search a record by taking three Fields, i.e File No, ID
Number, and File number form the user . and then display the search result if
found.

If not found it should show the message not found.

Can any help me pleae in these regards please.

Thanks,,

Khaksar
 
Hi

Create a new form based on the same table as your main form
Call the new form
Create a new button (call it ButtonFind)
Create 3 new text boxes
Text box 1 = Call it ID base this on the ID field in the table
Text box 2 = Call it FileNumber base this on the File number field in the
table
Text box 2 = Call it Number base this on the Number field in the table

Put this on the OnClick event of ButtonFind
Notes - Change MainFormName to wehat it is in your application


Private Sub ButtonFind_Click()
Dim strID As String
strID = Nz(DLookup("[ID]", "[TableName]", "[Number] ='" &
FrmSearch!NumberControl & "' AND [ID] = '" & FrmSearch!IDControl & "'AND
[FileNumber] = " & FrmSearch!FileNumberControl & ""), "0")
Dim msg, style, title, ctext, responce, mystring
Dim stDocName As String
Dim stLinkCriteria As String
If strID = "0" Then
msg = "There is no record found" & vbCrLf & vbCrLf & "Do you want to
create a record now?"
style = vbYesNo
title = "No Record Found"
responce = MsgBox(msg, style, title)
If responce = vbYes Then
DoCmd.OpenForm "MainFormName", acNormal, "", "", , acNormal
DoCmd.GoToRecord acForm, "MainFormName", acNew
End If
Else
Me.User_name = strID
msg = "The record is in the database " & strID & vbCrLf & vbCrLf &
"Do you want to go to this record now?"
style = vbYesNo
title = "Record Found"
responce = MsgBox(msg, style, title)
If responce = vbYes Then
stDocName = "MainFormName"
stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End If
End Sub


Good luck

If you have problems post back - someone will help.
 
Thank you very much sir, I will try this code if i get any problem I will let
you know.

Thanks alot.
Khaksar.

Wayne-I-M said:
Hi

Create a new form based on the same table as your main form
Call the new form
Create a new button (call it ButtonFind)
Create 3 new text boxes
Text box 1 = Call it ID base this on the ID field in the table
Text box 2 = Call it FileNumber base this on the File number field in the
table
Text box 2 = Call it Number base this on the Number field in the table

Put this on the OnClick event of ButtonFind
Notes - Change MainFormName to wehat it is in your application


Private Sub ButtonFind_Click()
Dim strID As String
strID = Nz(DLookup("[ID]", "[TableName]", "[Number] ='" &
FrmSearch!NumberControl & "' AND [ID] = '" & FrmSearch!IDControl & "'AND
[FileNumber] = " & FrmSearch!FileNumberControl & ""), "0")
Dim msg, style, title, ctext, responce, mystring
Dim stDocName As String
Dim stLinkCriteria As String
If strID = "0" Then
msg = "There is no record found" & vbCrLf & vbCrLf & "Do you want to
create a record now?"
style = vbYesNo
title = "No Record Found"
responce = MsgBox(msg, style, title)
If responce = vbYes Then
DoCmd.OpenForm "MainFormName", acNormal, "", "", , acNormal
DoCmd.GoToRecord acForm, "MainFormName", acNew
End If
Else
Me.User_name = strID
msg = "The record is in the database " & strID & vbCrLf & vbCrLf &
"Do you want to go to this record now?"
style = vbYesNo
title = "Record Found"
responce = MsgBox(msg, style, title)
If responce = vbYes Then
stDocName = "MainFormName"
stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End If
End Sub


Good luck

If you have problems post back - someone will help.

--
Wayne
Manchester, England.



khaksar said:
Hello every body,
I am making a DB in access. I have a table which contains fields given below
: -
1. Name
2. ID number
3. Gender
4. City
5. file no
6. Company Name
7. Address.

I am ok with this table and my table is working properly. Now i want to make
a Form that has to search a record by taking three Fields, i.e File No, ID
Number, and File number form the user . and then display the search result if
found.

If not found it should show the message not found.

Can any help me pleae in these regards please.

Thanks,,

Khaksar
 

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