Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 27th, 2006, 01:36 PM
Authorized User
 
Join Date: May 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Posting the value of an unbound form field into a

Posting the value of an unbound form field into a table field in access.
I have created a table with 3 fields. StartNum, EndNum, TotalCount.
When I create a form based on this table I have placed the fields in the form. For the Total count field I edited the control source to show =[EndNum]-[StartNum]+1 and it displays the correct value however the value does not enter into the original table only the value typed into the startnum and EndNum reflect. What am I missing?

EB
__________________
EB
 
Old May 27th, 2006, 01:44 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

You have a couple of options...

An unbound field isn't tied to any part of the table, hence it cannot update the value.

If you were to follow traditional RDMS design methodology, you would not store the value, but just calculate it whenever you display the data.

The other option, is to bind the textbox to the correct control. To calculate it, you would then put an event on the other two boxes, so that when you leave either of those fields, it updates the value in the calculated field.

My personal opinion is that the first option would be the best, but yell if you need a hand with either of them..

Mike

Mike
EchoVue.com
 
Old May 27th, 2006, 02:37 PM
Authorized User
 
Join Date: May 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your response, however, I am required to store all inputs and values.
Here is what I am trying to do. I am creating this database to capture tickets in a range of numbers ex, 1000 to 2000 that is a total of 1001 tickets total so I am having the field capture that value when inputed so that I can capture a running total as more tickets are inputed ex 2001 to 3000 that is another 1000 tickets.
I am not able to capture the running totals because the totalcount field in the table does not capture the value from the form's control field. Is there a way to modify my table and form to post this data?

EB
 
Old May 27th, 2006, 02:43 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Are you familiar with VBA at all?

Mike
EchoVue.com
 
Old May 27th, 2006, 02:44 PM
Authorized User
 
Join Date: May 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not really. Would it be hard to code?

EB
 
Old May 27th, 2006, 02:57 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Not really...

I am assuming you'll enter the EndNum last, so go to that text box, look at the properties, and choose the On_LostFocus event. Next click the little button next to it and choose the Code option.

In the sub procedure which is built enter something like

TotalCount = EndNum - StartNum + 1

Some variations that you may need would include...

Me.TotalCount = Val(Me.EndNum) - Val(StartNum) +1

Then just set the recordsource of the TotalCount text box to the field in the table, instead of the formula. It should auto populate when you tab or click out of EndNum.

Hope that helps,

Mike

Mike
EchoVue.com
 
Old May 27th, 2006, 03:01 PM
Authorized User
 
Join Date: May 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you Mike, I will try that and let you know what I come up with.

Thank you

eric

EB
 
Old May 27th, 2006, 04:35 PM
Authorized User
 
Join Date: May 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Mike

Thank you very much. That worked. =)

EB
 
Old May 27th, 2006, 04:38 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Good to hear, thanks!

And welcome to the Forum - I am sure you'll find it and excellent resource when trying to figure stuff out. More heads are always better than one!

Have a good one :)

Mike

Mike
EchoVue.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
unbound field in subform chacquard Access VBA 4 February 7th, 2007 10:01 AM
unbound field in a form zanza67 BOOK: Access 2003 VBA Programmer's Reference 0 September 3rd, 2005 01:46 PM
Unbound field lee27 VB Databases Basics 1 January 5th, 2005 07:53 AM
How to bind unbound field ? cjordan BOOK: Professional Crystal Reports for VS.NET 1 January 23rd, 2004 01:34 PM
Retreiving data from unbound field? lanctotd Access VBA 7 July 28th, 2003 07:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.