Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Who can help me here?

Status
Not open for further replies.

Jarnut00

Technical User
Jan 24, 2002
32
0
0
US
I'm trying to make a command button that on click will pop up a msgbox titled "Job Locater" with the message "What job do you want to find?" prompting the user with an inputbox. Upon hitting enter will search a database and return a pop up saying where the the job is and the jobs status.

I am failing miserbaly.

any ideas? Jarnut00 is a member of
 
Code:
Private Sub cmdjoblocate_Click()
'Dim mydb As Database, MYTABLE As DAO.Recordset
Dim MYTABLE As DAO.Recordset
Dim sJob As String, sLoc As String
Set mydb = CurrentDb
Set mydb = DBEngine.Workspaces(0).Databases(0)
Set MYTABLE = mydb.OpenRecordset("3year", DB_OPEN_TABLE)
MYTABLE.Index = "Job Number"
MYTABLE.Index = "Location Text"


  sJob = InputBox("What Job Number do you want to find?", _
   "JOB LOCATER")

  If IsNull(sJob) Then
    MsgBox "Please enter a Job Number"
    Exit Sub
  Else
    sLoc = DLookup("Location Text", _
    "MYTABLE", "Job Number =" + sJob + "'")
   'sLoc = DLookup("Location Text", _
    '"MYTABLE", "Job Number = " & sJob)
  End If
 
  MsgBox ("Job Number: " & sJob & _
   " WAS FOUND! " & vbCrLf & _
   "and is located in: " & sLoc & ".")
   
End Sub

I am still getting nothing returned. I'm losing it here! LOL. I click the button, it brings up the messagebox, i type in the job number, hit enter or click ok and nothing gets returned to me....=-/ I'm goin crazy here =-] Jarnut00 is a member of
http://www.teambitm.com/bitm.JPG /img[/img] /url]
 
I don't know how to explain this any better. You are trying to open a record set (unnecessary step) and query the record set using DLookup (not possible). If you would just use the code I provide with the coorect table and column names, it would work. Try pasting the following into your module and see if it works!

Private Sub cmdjoblocate_Click()

sJob = InputBox("What Job Number do you want to find?", _
"JOB LOCATER")

If IsNull(sJob) Then
MsgBox "Please enter a Job Number"
Exit Sub
Else
sLoc = DLookup("Location Text", _
"3Years", "Job Number =" + sJob + "'")
End If

MsgBox ("Job Number: " & sJob & _
" WAS FOUND! " & vbCrLf & _
"and is located in: " & sLoc & ".")

End Sub Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
I think what he is not telling you is that he want's you to write it for him. Helping is one thing, writing it for him is another.
 
hey geek!

that is not what i was doing! I had written code already and couldn't figure out why it wasn't working.

Don't play that game man.
Anyways thanx for your help everyone!
I did get it to work with the code that throadbnet made up.
I had to change on or 2 things.
But thank you! I can now continue writing MY OWN code and doing MY WN work. Jarnut00 is a member of
http://www.teambitm.com/bitm.JPG /img[/img] /url]
 
Jarnut,

I re-read my post and realized that I did come across as a smartass. I only meant to tease you. I know what it's like to get stumped. I learned Access the same way you are, by just jumping in and asking questions.

Good luck.
 
Thank you for realizing that. I think I mentioned in one of my earlier posts that am not a lamer comp user. I'm not lazy. I do give ofrth effort. I also mentioned that I'm a moderator in the Admin-Mod forums and in my Paintball team Forums. I really hate n00bs who haven;t even given an effort and basically in their entire thread only ask one question...."Can you set my server up for me?"

I hate that....but thank you for saying that :LOL

-Ben Jarnut00 is a member of
http://www.teambitm.com/bitm.JPG /img[/img] /url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top