A very simple question

InterGladiator

Registered User.
Local time
Today, 13:03
Joined
Apr 20, 2006
Messages
20
Hi,

Could you, please, write me down how to step one record forward/backward in a table using VB code?

Thank you,
Attila
 
How about using the wizard to put a command button on a form that will do it for you. Then go look at the code the wizard put behind the button.
 
Thank you, that sounds like a good idea. I haven't got Access on my home computers but I will try it out on Monday when I get back to work.
 
There is no code for the navigation button bar... Have you got other solutions?
 
How about using the wizard to put a command button on a form that will do it for you. Then go look at the code the wizard put behind the button.
Did you try my suggestion?
 
wazz: Yes, and I answered. I keep getting error messages.
RuralGuy: the wizard does not offer to put a command button on the form - or do I do something wrong?
 
You may need to turn on the Wizard. 2nd from the left of the same toolbar is the wizard's wand; click it one time and try placing a command button again.
 
Thank you, it was turned off. So I put a next button onto the form a let Access do the programming. The problem it does not works. I get this error message when I click the button: "You can't go to the specified record"
 
Some additions: My form contains two subforms and the second subform is driven by the first subform. Moreover, the first subform is filtered, it didn't show all records. But, I guess, I still should be able to step forward one record or find a particular record. The question is just how?
 
how many records are in the query/table? Turn on the Nav buttons and try going to the next record. Do they work the same?
 
It's not so simple... Please see the following screenshot:

form.jpg


The main form is bound to nothing as it serves only as a placeholder for the two subforms. The first subform (left) shows certain orders that meet some requirements (filtered). The second (right) subform shows parts that are needed for the order that is selected on the first subform. So the second subform is driven by the first.

There is a next and a search button. When the user clicks the next button, the first subform should step to the next available record. When the user clicks the search button, the first subform should step onto the record which order number is the same that is entered into the text box just on left of the button. Of course, the right subform refreshes to show the parts for the actual record of the left subform.

So, how can I do this?
 
Well that explains the error when you press the Next button. If you set the focus to the subform (a 2 step process) the the code that Wazz gave you in the other thread will work.

Me!SubFormControlName.SetFocus
Me!SubFormControlName.Form.ControlNameOnSubForm.SetFocus
DoCmd.GoToRecord , , acNext

Using your ControlNames of course.
 
I tried your solution (SetFocus method) but I got "Cannot go to the specified record" error message again.

Would you be so kind to look into my database and locate the source of the problem?

You can download my database from http://ambrozai.uw.hu/anyag/FOT.zip (it is just 35 KB zipped).

I changed the texts and captions from Hungarian to English for you.

Thank you,
Attila
 
Hi Attila
See if this works the way you want. Your SubFormControl and your SubForm were not named the same (which is the way I like it - no confusion).
 

Attachments

Yes! It is fine now! Thank you very much!!! I created the code for the search button too and it works well now also.
Thank you again,
Attila
 

Users who are viewing this thread

Back
Top Bottom