Sub Form With All Unbound Text Boxes To Store Record

Ashfaque

Search Beautiful Girls from your town for night
Local time
Tomorrow, 04:09
Joined
Sep 6, 2004
Messages
897
Hi,

As a part of reducing traffic on file server, I am planning to read less record on the form and hence I tried removing forms record source. (Attached sample db)

I kept all unbound textboxes onto the forms and save new record to the table using codes back of the command button. This is working great with main form. But doesn’t with sub form. I tried removing record source of sub form and keeping unbound text boxes to appear record if it exists.

If you enter 1 in InvNum text box on main form, you will find it brings record. I don’t want to show the record on the sub form unless I call it from main form.

How can I use the same trick of unbound text boxes with sub form too?

Please extend your help.

With kind regards,

Ashfaque
 

Attachments

Hi -

You should also be able to use the same approach to unbind the subform.

I am not sure what your specific question is. What part of this do you have questions about?

- gromit
 
Thanks gromit,


My question is about subform's record. How can I save the sub form's record with code. Like what I did with main form. Bcz all the text boxes in main form are UNBOUND and they will not save information unless I click save cmd button.

As the relationship is established on InvNum field in between both form, I need to store subform's record only when I save main form's record.

In other words If user dont click save cmd button to save main form's record, the sub form's record also should not be saved.

I hope I am clear this time.

So how can I do that ? Bcz like main form, all the fields on subfrorm are NOT unbound.

WIth kind regards,
Ashfaque
 
Hi Ashfaque -

You write the subform records essentially the same way that you wrote the main form. The fields on the subform are accessible to the main. The syntax can be a little confusing but here is the basic format:

Forms![main form name]![subform control name].Form![control name]

(See http://support.microsoft.com/?kbid=209099)

There also can sometimes be issues with Record ID's and storing foreign keys. The solution is usually to first create the record having the primary key, store that number and then write the record requiring the foreign key.

Does that help?

- g
 
The power of Access is in its handling of bound forms/reports. The way to reduce server traffic is by using queries with selection criteria as RecordSources, NOT by using unbound forms/reports. When you use unbound forms/reports, you must recreate all the functionality that Access gives you automatically if only you take advantage of it.
 
Hi Pat -

So you recommend building a query that returns only the desired RecordSet and then opening the form based on that query?

- gromit
 
Absolutely! It is important to take advantage of your toolset. If you have an overwhelming desire to write code, switch to VB.Net or C++ or COBOL for that matter.
 
Sorry..confusion..

Do you mean I have to bound all the fields on main form ans sub form as well and keep both form's record souce 2 different queries. And place a unbound text box in which I will enter the invoice number and if it is exists, it would bring to display and if not, will be ready to accept it as new rec ? What about the subform record ?

As the matter is bothering me since long back, it would be HIGHLY appreciated if you could please apply it with my attached db and reload it so that I could also know it and can apply on my real db.

Thanks for your valuable time.

With kind regards,

Ashfaque
 
You don't need an example from me. If you use a bound form, you can add an unbound combo to that form to use to find records. The wizard will do all the work. Keep in mind that if your form is not bound, the wizard will not show you the option to "find a record on this form".
 

Users who are viewing this thread

Back
Top Bottom