stop form going to new record (1 Viewer)

leemansiuk

New member
Local time
Today, 05:00
Joined
Jun 8, 2006
Messages
6
i wonder if anyone can help with this problem i cant seem to work out.

i have a bound form linked to an orders table, including some required fields. when i use the navigation buttons of the form to scroll thorugh the orders i can get to the end where the form expects you to make a new order. but i have a button to add a new order.

i want to stop the user being able to go past the last record in the orders table. or enable them to get back to the last order. currently if the user goes past the last record (making a new order) there is no way to get back to the last record. using the navigation back button causes errors as the required fields are blank and access tries to save the order, thinking i want to make a new one.

i hope this makes sense.

i have tried setting the Allow Additions setting of the Form to No. but this causes problems when there is no data in the orders table. opening the form produces a blank form, showing no fields or buttons at all.

i would be greatful for any advice, maybe i am doing something fundamentally wrong?:confused:
 

Bobadopolis

No I can't fix it dammit!
Local time
Today, 05:00
Joined
Oct 6, 2005
Messages
77
You could put some code in the OnCurrent event of the form:
Code:
Me.AllowAdditions = IIf(Me.RecordsetClone.RecordCount = 0, True, False)

This turns AllowAdditons off if there are records, and on if there are none (hence your control won't disappear).

Bobadopolis
 

leemansiuk

New member
Local time
Today, 05:00
Joined
Jun 8, 2006
Messages
6
thanks for that,

i tried what you suggested, it doesnt quite work as i would like. the form is still blank (no fields or buttons, only title) when there are no orders. i placed the code in the forms On Load event and solved that. but there are still problems

thanks again

I'm still working on it
 

Bobadopolis

No I can't fix it dammit!
Local time
Today, 05:00
Joined
Oct 6, 2005
Messages
77
Make sure in the Form's property sheet you set AllowAdditions to "Yes". The code will take care of it thereafter...

What other problems are you having?

Bobadopolis
 

leemansiuk

New member
Local time
Today, 05:00
Joined
Jun 8, 2006
Messages
6
thanks for the reply, that worked

i have worked around the problem i had, although i'm not really happy with it. this is what i have done

may overall problem was stopping the user navigating to a new record. i wanted the user to only view existing orders and click a button to make a new order. also to allow the user to add a record if there were none in the orders table already.

I used a Main order form, using your code in the On Current event. from this form a button opens a similar form (add new order) to make a new order. once the order is complete the user has to close the form, returning to the Main order form. to view the order just made an update button has to be clicked which requries the orders table (Me.Requery), then the user has to scroll through the orders (using the navigation buttons) to find the order they just made. from there some reports can be printed such as invoice etc.. using some other buttons on the form

I think there must be a better way of achiving this, i am new to access and have been working most things out as i go. any more suggestions would be very welcome?
 

Bobadopolis

No I can't fix it dammit!
Local time
Today, 05:00
Joined
Oct 6, 2005
Messages
77
leemansiuk said:
to view the order just made an update button has to be clicked which requries the orders table (Me.Requery)
Why not attach the requery to the OnClose event of the input form (provided the viewing form stays open):
Code:
[Forms]![[I]myForm[/I]].Requery

leemansiuk said:
the user has to scroll through the orders (using the navigation buttons) to find the order they just made
You could use the combo box wizard for a simple method to navigate to a desired record in a form. An alternative to this is to filter the form's RecordSet using an unbound combo. Search the forum - there are plenty of examples of this.

Bobadopolis
 

Users who are viewing this thread

Top Bottom