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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GoToRecord............................................................

Status
Not open for further replies.

jdwm2310

Technical User
Jul 26, 2001
396
US
What am I doing wrong, I have a combobox with employee name, I want to click on a person's name and view their record.

I created gotorecord in the combo box event procedure.
Here's how it look:

Private Sub Employee_Data_Click()

DoCmd.GoToRecord([acDataForm],[Employee_Data],[acGoTo],)

End Sub

Please guys I really need your help...;-)
 
Hi!

To use that method you need to know the record number you are going to. Try this instead:

Private Sub Employee_Data_Click()

Dim rst As DAO.Recordset

Set rst = Me.RecordsetClone
rst.FindFirst "EmployeeName = '" & Combobox.Text & "'"

If rst.NoMatch = True Then
MsgBox("That name is not in the database.")
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

End Sub

I have never had any trouble with this sort of code, but I have heard of others who can't seem to get to the right record. If you have that sort of trouble repost and maybe we can figure something out.

hth
Jeff Bridgham
 
jebry,

I got a run-time error 3070. Does not recognize "EmployeeName"

This is what I did:

Private Sub Employee_Data_Click()

Dim rst As DAO.Recordset

Set rst = Me.RecordsetClone
rst.FindFirst "EmployeeName = '" & Employee_Data.Text & "'"

If rst.NoMatch = True Then
MsgBox ("That name is not in the database.")
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing

End Sub

Please Advice
 
Hi!

I'm sorry, I forgot to mention that EmployeeName is a field name that I just made up. You need to replace it with the field name that you used in your table.

Jeff Bridgham
 
you are not going to believe this but EmployeeName is the field name that I have. Why isn't it working??
The combo Box - Employee Data
Control Source - Employee Data
Row Source Type - Table/Query
Row Source - SELECTDISTINCTROW
The field name - EmployeeName
The name of the form - SERP DATA

Please Help................
 
Hi!

What's the recordsource of the form? I assumed that it contained all of the employee data. Is EmployeeName part of the table or query the form is built on? Is the combo box on the same form? BTW, a combo box used to search probably shouldn't have a control source, that can cause data corruption. If you can use employee data to search for the employeename, what is the difference between the two? How many columns does your combo box have, which one is displayed and which is the bound column? I'm sure we can solve this problem once I get some more information.

Jeff Bridgham
 
I got it thanks to you; my record source is SERP Plan Information. And the field was not EmployeeName but Employee Data....I inserted this fieldname into your coding and it worked!!!!!!!!!!!!!!!!! You are definitely the greatest...Thanks so much.... :-D
 
Hi!

Glad to help! :)

Sometimes all one needs to do is ask the right question!

Jeff Bridgham
 
jebry,

Help this is an emergency..I don't know what happened but now I get a warning sign stating that the name is not in the database...Another thing I get the records for differenct people...Oh man, help please....

My record source is - SERP Plan Information Table
Employee Data is part of this table.
Combo Box has a control source - Employee Data, Row Source Type - Table/Query,Row Source - SELECTDISTINCTROW, The field name in the query - EmployeeName. The EmployeeName and the Employee Data are the same information.
Combo Box- 2 column
 
Hi!

I can't emphasize enough, if you are going to use a combo box as a record search device, it cannot be the method to display the information once it is found. That is because, when a user finds a name in the combo box and clicks on it, the record they were on previously will be changed. A search combo box should not have a control source (Per my first post of August 30th). What you need to do is unbind the combo box and add a text box which is bound to the field for display purposes. You will also need to go through your table and reconstruct the corrupted data. I'm sorry about this, I guess I should have re-enforced my comment.

hth
Jeff Bridgham
 
Ok I unbinded the combo box and added a textbox. Do I enter the code you have me on Aug 29 in the combo box (event procedure.)
 
Hi!

You should be able to use the same code. One exception I would make would be to change the name of the combo box, you can call it cboEmployeeData or something like that, and change the code the same way. That will keep Access from becoming confused between the text box, combo box and field in the record source.

If you still have trouble, post your code and I will test it.

hth
Jeff Bridgham
 
I found an simpler method I added a command button in a form that's linked to the SERP Plan form, the button will open up the SERP Plan form and look up the record of the selected control.
I was wondering of adding another command button in the form that will allow me to directly enter a new record into the SERP Plan form without acutally going to the SERP Plan form. So when I click on the button the SERP Plan form opens a blank record and there I can enter new information. Any ideas or hints???
 
Hi!

Yes! In the click event of AddNewRecord command button put:

DoCmd.OpenForm "YourFormName", , , , acFormAdd

This will open the form in add mode.

hth
Jeff Bridgham
 
Hi,

How could I make the tables/queries untouchable..I just want the users to use the switchboard I created without them touching/editing the tables/queries, etc???
 
Hi!

That depends a little on the level of your user's abilities. If you go into Tools/Startup and uncheck every box there and make sure your switchboard is listed as the display form, then the user will have very little leeway. They would still be able to get to the database window by holding down the shift key when opening the database, but non-technical users will probably not know that trick. And the shift key can be turned off also.

hth
Jeff Bridgham
 
Cool idea. This is the final question I have a code that opens a specific form, the users can then view the record of the selected control however I don't want users to edit or update the records. (I also don't want to view it as preview)

Private Sub Command27_Click()
On Error GoTo Err_Command27_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "SIP/SESP Distribution"

stLinkCriteria = "[Employee Information]=" & "'" & Me![Name] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command27_Click:
Exit Sub

Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click

End Sub
 
Hi again!

Change the following line:

DoCmd.OpenForm stDocName, , , stLinkCriteria

to

DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly

Now the form will open in read only mode.

hth
Jeff Bridgham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top