473,408 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Clear SOME, not ALL controls on a Bound Form

imrosie
222 100+
Is it possible to do this???? My "newbieness" is showing here.

My form is based on a query (customer and order tables). The customers name is first selected in order to fill in data (OrderID, OrderDate, Address, City, Account No. etc.) Unfortunately it also fills in all of the controls(bound and unbound).and specifically the last 'OrderID' and 'OrderDate' and P.O. Number.

To start a new order, I'd like to keep the basic customer info in the controls; i.e. Name, address, city, Acct. number, but CLEAR OUT the P.O. Number, OrderID and OrderDate (bound controls). OrderID is based on an autonumber.

Does anyone have a recommendation? I've looked everywhere, many tutorials. thanks
Rosie
Aug 9 '07 #1
7 1929
FishVal
2,653 Expert 2GB
Is it possible to do this???? My "newbieness" is showing here.

My form is based on a query (customer and order tables). The customers name is first selected in order to fill in data (OrderID, OrderDate, Address, City, Account No. etc.) Unfortunately it also fills in all of the controls(bound and unbound).and specifically the last 'OrderID' and 'OrderDate' and P.O. Number.

To start a new order, I'd like to keep the basic customer info in the controls; i.e. Name, address, city, Acct. number, but CLEAR OUT the P.O. Number, OrderID and OrderDate (bound controls). OrderID is based on an autonumber.

Does anyone have a recommendation? I've looked everywhere, many tutorials. thanks
Rosie
Hi, Rosie.

There is no need to clear controls on a bound form (unless they itself are unbound), they are being cleared automatically when you go to new record. You need to keep some controls filled with last entered value rather than clear others. This could be easily achieved setting DefaultValue property of a control once the control was updated.
Expand|Select|Wrap|Line Numbers
  1. Private Sub SomeControl_AfterUpdate()
  2.      SomeControl.DefaultValue = SomeControl.Value
  3. End Sub
  4.  
Aug 9 '07 #2
imrosie
222 100+
Hi, Rosie.

There is no need to clear controls on a bound form (unless they itself are unbound), they are being cleared automatically when you go to new record. You need to keep some controls filled with last entered value rather than clear others. This could be easily achieved setting DefaultValue property of a control once the control was updated.
Expand|Select|Wrap|Line Numbers
  1. Private Sub SomeControl_AfterUpdate()
  2.      SomeControl.DefaultValue = SomeControl.Value
  3. End Sub
  4.  

Hi FishVal,

Thanks for your suggestion. I think I understand.......Do I put this in each control's default value line, for the ones' that I want to retain?. Then, when I click the cmd button (the macro that clears the entire form) the person's name, city, addr, etc. would remain? How would I clear the form then, in the case of the next person? When I'm ready to enter a new Order for the next person, would I have information from the previous person
retained in those controls?

Would I need another cmd button if that's the case, to actually clear all controls, including the 'default' values?

I just took a look at the default value line on the form for each control, it does NOT take me into the VB 'code' (to put this routine) it gives me only the option to use Expression Builder. Help

I'm still speaking Newbie here.....
thanks so much
Rosie

Thanks
Aug 9 '07 #3
missinglinq
3,532 Expert 2GB
I believe FishVal thought you were entering a record, then wanted to enter a new record with some of the same data. It sounds to me like you're actually pulling up an old record, and then want to create a new record for the same Customer but with order numbers, etc blank; is that correct? If so, put a button on your form and this code behind it:
Expand|Select|Wrap|Line Numbers
  1. Private Sub ClonePartialRecord_Click()
  2. 'Copy fields from original record to variables
  3. NewField1 = Me.YourField1
  4. NewField2 = Me.YourField2
  5. NewField3 = Me.YourField3
  6.  
  7. 'Go to a new record
  8. DoCmd.GoToRecord , , acNewRec
  9.  
  10. 'Plug in old values into new record
  11. Me.YourField1.Value = NewField1
  12. Me.YourField2.Value = NewField2
  13. Me.YourField3.Value = NewField3
  14. End Sub
There's one caveat! None of the fields you're copying to the new record can be the Primary key, because this will throw an error. A Primary Key can only appear in one record!
Linq ;0)>
Aug 9 '07 #4
imrosie
222 100+
I believe FishVal thought you were entering a record, then wanted to enter a new record with some of the same data. It sounds to me like you're actually pulling up an old record, and then want to create a new record for the same Customer but with order numbers, etc blank; is that correct? If so, put a button on your form and this code behind it:
Expand|Select|Wrap|Line Numbers
  1. Private Sub ClonePartialRecord_Click()
  2. 'Copy fields from original record to variables
  3. NewField1 = Me.YourField1
  4. NewField2 = Me.YourField2
  5. NewField3 = Me.YourField3
  6.  
  7. 'Go to a new record
  8. DoCmd.GoToRecord , , acNewRec
  9.  
  10. 'Plug in old values into new record
  11. Me.YourField1.Value = NewField1
  12. Me.YourField2.Value = NewField2
  13. Me.YourField3.Value = NewField3
  14. End Sub
There's one caveat! None of the fields you're copying to the new record can be the Primary key, because this will throw an error. A Primary Key can only appear in one record!
Linq ;0)>
Thank you thank you....you're so right. I'm pulling up an old record, you got it exactly. I'm concerned about the caveat....my orderid is a primary key autonumber in the Order tables (which is a part of the form's supporting query).
I need the OrderID (a new autonumber for each new order), it's used as the foreign key to all the other queries (connecting it also to the CustomerID).....

What can I do in this case....Oh my goodness if this can work I would be ecstatic......you're my hero.thanks

Rosie
Aug 9 '07 #5
missinglinq
3,532 Expert 2GB
If orderid is a primary key/autonumber it shouldn't be showing on your form. Autonumbers are supposed to remain in the background or as one guru once said, they're not fit for human consumption! At any rate, even if it does show up on your form, you simply treat that field like you do the one for your Order Numeber, you don't include it in the fields that are assigned to variables and then entered in the new record! When you create the new record Access will generate the new autonumber.

Linq ;0)>
Aug 9 '07 #6
imrosie
222 100+
If orderid is a primary key/autonumber it shouldn't be showing on your form. Autonumbers are supposed to remain in the background or as one guru once said, they're not fit for human consumption! At any rate, even if it does show up on your form, you simply treat that field like you do the one for your Order Numeber, you don't include it in the fields that are assigned to variables and then entered in the new record! When you create the new record Access will generate the new autonumber.

Linq ;0)>
Missinglinq,
this works great! thanks...well on to the next issue. take care.
Rosie
Aug 10 '07 #7
missinglinq
3,532 Expert 2GB
Glad we could help, Rosie!

Linq ;0)>
Aug 10 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: @ndy | last post by:
Hi developers, i've a problem with my tabcontrol. Before i open my form with a tabcontrol with 3 tabs (Frm_Files|Frm_Lines|Frm_Guarantee) all the controls on al the tabs must be enabled. With...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
5
by: karsagarwal | last post by:
I have a bounded form and after I click the button to update/save. THe fields are still there. Is there a way to clear off the fields in the bounded form. Thanks, SA Here's the code that I...
32
by: =?Utf-8?B?U2l2?= | last post by:
I have a form that I programmatically generate some check boxes and labels on. Later on when I want to draw the form with different data I want to clear the previously created items and then put...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.