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
 
Create, test and save the query with the parameter. In the click event of the button use DoCmd.OpenQuery method to open the query. Opening the query will cause the parameter window to display.

DoCmd.OpenQuery "qryJobLocations", , acReadOnly
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.
 
didnt use a query...
I'm hard coding it in the background....
Code:
Private Sub joblocate_Click()
' this procedure will use records from 3year and cpnames for vitals
'******************************************
'open 3year and get some of the information
'******************************************
'On Error GoTo Err_JobNumberCommandButt_Click
Dim mydb As Database, MYTABLE As Recordset
Set mydb = CurrentDb
Set mydb = DBEngine.Workspaces(0).Databases(0)
Set MYTABLE = mydb.OpenRecordset("3year", DB_OPEN_TABLE)   'open the table
msg = "What is the Job Number you would like to find?"
title = "JOB LOCATER"
answer = InputBox(msg, title)   

On Error GoTo Err_joblocate_Click

Exit_joblocate_Click:
   Exit Sub

Err_joblocate_Click:
    MsgBox Err.Description
    Resume Exit_joblocate_Click
    

End Sub
Jarnut00 is a member of
 
What you suggested for me created a new table and when i enetered text it showed up in ever record. I'm kinda stuck between a rock and a hard place here.....

My boos (father) believe in the school of hard knocks.
I have no training or schooling in access or VB, howver I am comming along. He simply threw the computer at me and said, learn it. =/

I may need a walk thru on this. Jarnut00 is a member of
http://www.teambitm.com/bitm.JPG /img[/img] /url]
 
Create a new query with the following syntax and name it qryJobLocations:

SELECT [job is], [jobs status] FROM 3year WHERE [JobNo] = [What job do you want to find?];


Here is what your procedure will look like:

Private Sub joblocate_Click()
DoCmd.OpenQuery "qryJobLocations", , acReadOnly
End Sub

Hope this helps.
 
That works but it doesn't =-]

It pops up a box and asks me to enter Job is, Job status, and then the job number....but ir returns me a new table with all sorts of records...

I dont want that...

I want it to ask me what job i want to find, type in job number, return me a "error box" or something along the lines of that which you can't type into stating the location and status of the job Jarnut00 is a member of
http://www.teambitm.com/bitm.JPG /img[/img] /url]
 
Why not use an Inputbox, take the value from that and use it in the DLookup function or recordset iteration (DIM rs as DAO.Recordset), and msgbox your results to the user? If you have a sample of the table and which fields you want returned you can email it to me (in A97 format) and I will throw it together. Or am I not quite understanding your request?



prodevmg@yahoo.com
ProDev, MS Access Applications B-)
May God bless you in the year 2002.
 
bmoyer23 suggested the same easy solution that I did. He gave you details but you can't copy his sample query AS IS and hope it works in your database. You must use column names in your table.

The query isn't returning a New Table. It is returning a record set. It is like a virtual table.

Modify bmoyer23's query as follows.

SELECT * FROM 3year
WHERE <YourJobNoColumn> = [What job do you want to find?];
Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
Broadbent. I see what you are saying. And I didn't copy his query and use it in mine. I did chaneg the field names.

I dont want a virtual table returned. I want just one two fields of one record returned.

ex.

==============================
Job Number: 201876 WAS FOUND!
And is located in: COMP dept.
==============================

but as a msg box. Or even If i have to make a new form
But that is what I'm reaching for. This is going to be an application distributed throughout this place of business
mainly for production and job updating. So that sales people dont need phone customers back because they had to walk thru the offices and the plant to find a job jacket.
Simply all they have to do is click the button, type in the job number, and get it reutrned where it is.

Thanx for all your help and I'm sorry if I'm being a pain.
I really wish I went to school for this stuff cause it is cool as hell. Jarnut00 is a member of
http://www.teambitm.com/bitm.JPG /img[/img] /url]
 
Ok. It helps to have a complete explanation. You can develop a VBA module in the click event similar to the following.

Private Sub cmdFindJob_Click()

Dim sJob As String, sLoc As String
sJob = InputBox(&quot;What job do you want to find?&quot;, _
&quot;Find Job&quot;)

If IsNull(sJob) Then
MsgBox &quot;Please enter a Job Number&quot;
Exit Sub
Else
sLoc = DLookup(&quot;JobLocation&quot;, _
&quot;tblJobs&quot;, &quot;JobNo='&quot; + sJob + &quot;'&quot;)
End If

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

End Sub
Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
Thanks !!!

I'll give that a go!
I know about people bing pains in forums.
I admin my own forum now and I moderate
Admin Mod forums for the Game Counter-Strike.
a game and I'm 25 years old. Heh...

Anywyas...lemme give that a go. Jarnut00 is a member of
http://www.teambitm.com/bitm.JPG /img[/img] /url]
 
You're not pain but sometimes I am! ;-) Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
LOL

Ok...I tried what you gave me. AND IT WORKS!
Up until it has to go out and get the information from the table and then return it into a new message box with the location info.

I added some code to it to try and tweek...same result everytime. Nothing comes up in immediate window. I should say I am using Office XP.

Table: 3year
Field: Job Number
Field: Location Text

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(&quot;3year&quot;, DB_OPEN_TABLE)
  sJob = InputBox(&quot;What Job Number do you want to find?&quot;, _
   &quot;JOB LOCATER&quot;)

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

'''look in immediate window to see if it works at all
  debug.print [mytable]![customer name]

 
End Sub

Jarnut00 is a member of
http://www.teambitm.com/bitm.JPG /img[/img] /url]
 
Also, you may want to use the ampersand to concantenate your expression instead of the plus sign. Also there was a space after the first tic mark (apostrophe) before sJob.

DLookup(&quot;Location Text&quot;, _
&quot;MYTABLE&quot;, &quot;Job Number = '&quot; & sJob & &quot;'&quot;)


Is the job number numeric? If so, get rid of the tick marks (') before and after the Job Number.

DLookup(&quot;Location Text&quot;, _
&quot;MYTABLE&quot;, &quot;Job Number = &quot; & sJob)
prodevmg@yahoo.com
ProDev, MS Access Applications B-)
May God bless you in the year 2002.
 
Thanks Lonnie. I thought that I fixed the single quotes. I just noticed your recommendation to use the same process - Inputbox and DLookup. Sorry I missed that earlier.

Jarnut00,

Theer is no need to open a record set. DLookUp searches the actual table. If you need to return more than one column, you can use additional Dlookups or you can create a record set based on a query.

The Debug.Print statement is attempting to print a non-existing value. So nothing will show up.

Could yo clarify what you really want? Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
ok. here is what i want....

==============================
Job Number: 201876 WAS FOUND!
And is located in: COMP dept.
==============================

but as a msg box. Or even If i have to make a new form
But that is what I'm reaching for. This is going to be an application distributed throughout this place of business
mainly for production and job updating. So that sales people dont need phone customers back because they had to walk thru the offices and the plant to find a job jacket.
Simply all they have to do is click the button, type in the job number, and get it reutrned in another popup (like the message box that pops up on click) where it is if the job was found or that it was an invalid job number if not found and prompt the user to try again.

everything works until it goes to search.
nothing happens.
i dont even get a message box back saying that it was an invaild job number.

it seems to stop running the code when it gets to

Code:
 If IsNull(sJob) Then
Jarnut00 is a member of
http://www.teambitm.com/bitm.JPG /img[/img] /url]
 
The code I provided creates a message box. I tested the process on a similar table. Do you get an inputbox asking for the job number? Do you enter a job number? If you do then sJob will not be Null.

DLookup should execute. Are the column and table names correct in the DLookup function? If yes, then DLookup should load a value into sLoc.

The msgbox should then display the message regarding the job and location. It's that simple. Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
Can you send the code to me?

tlbroadbent@hotmail.com Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top