writing code for a button.

laurat

Registered User.
Local time
Today, 02:20
Joined
Mar 21, 2002
Messages
120
I have a form that is password protected. Once the correct password is entered it asks the user for the IRR # which they want to update. The user enters the number and is taken to that record. The problem is the user may wish to edit another record while in the form. As of right now they have to exit the form and then re-enter causing them to have to re-enter the password. Is there code I can write on a button I create that will just prompt the user for the number of the next record they wish to update. I have tried using the wizard when I create a button that causes the button to find a record, but it is not working. ANy ideas??
 
Last edited:
Use the wizard to create a combo box. Use the below code in the combo boxes AfterUpdate event...

Me.RecordsetClone.FindFirst "[RecordID] = " & Me![cbSearch]
Me.Bookmark = Me.RecordsetClone.Bookmark

My combo box is named cbSearch and the field name from the table I am searching is named RecordID.

HTH
 
Thank you, that would work, but the problem is there are currently about 3000 records in the table and that will continue to grow. It will be difficult for the user to scroll down and search for their number. I would like a way that prompts the user to just type in the specific number they want. Any other suggestions???
 
Can the users type their number in a text box? You could use the code I gave you with a command button that searches for the number they typed in the text box.
 
The users could type in a text box. Could you explain it a little bit more though. Where would the code go, on the text box or on the command button??
 
The text box would be unbound. The code would go with the command button. The user will need to click the command button to search for the number they typed in the unbound text.

HTH
 
I apologize, I am not very good at writing code so let me see if I have this right. I create an unbound text box, this is what the users type the number in they wish to search for. I also create a command button and place the following code in the On_Click() event:

Me.RecordsetClone.FindFirst "[RecordID] = " & Me![cbSearch]
Me.Bookmark = Me.RecordsetClone.Bookmark

where RecordID is the table name that I want it to look in and cbSearch is the field it is searching in. Is this correct and is there anything else I need to do? Thank you so much for all of your help.

Laura
 
Almost.

[RecordID] is the control source (field name from the table) and [cbSearch] is the name of the unbound text box.

This would go in the OnClick event of your button...

Private Sub bSearch_Click()
Me.RecordsetClone.FindFirst "[IRR] = " & Me![TextBox]
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

HTH
 
Thank you so much, that worked!!! Now let's just hope the users like it when I show it to them!!

Thanks again for all your help and patience with my many questions!

Laura
 

Users who are viewing this thread

Back
Top Bottom