473,508 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Value auto-calculated via query doesn't "stick" in field

lwwhite
16 New Member
Access 2003. I have a form (form view) with a subform (datasheet view). The form has a map_id field and each record on the subform also has a map_id field. I want the fields on the form and subform to automatically display the next available number in a defined sequence when I add a new record to either. I have been able to successfully generate and display the next available number in the form and datasheet (using a query), but I can't make the value "stick." That is, I add a new record and "1234" appears in the field. I save the record. I add another new record. "1234" appears in that field, too, when it should be "1235." I have found that if I actually click in the field and then Save, the value does stick. However, this is not an intuitive workflow for my users. Any suggestions on how to resolve this issue are greatly appreciated.
Feb 7 '07 #1
3 2096
nico5038
3,080 Recognized Expert Specialist
To prevent trouble, I generally INSERT such a record from code and then show an update form. When the user cancels the form I issue a DELETE. The only problem can be that when multiple users are inserting rows, a gap can be created this way...
The other solution would be to issue the new number in the BeforeUpdate/BeforInsert event of the form.
To get the next number use a DMAX() in the event like:
Me.ID = DMAX("ID","tblYours") + 1
This will however "hide" the new value for the user.

Nic;o)
Feb 7 '07 #2
MMcCarthy
14,534 Recognized Expert Moderator MVP
Access 2003. I have a form (form view) with a subform (datasheet view). The form has a map_id field and each record on the subform also has a map_id field. I want the fields on the form and subform to automatically display the next available number in a defined sequence when I add a new record to either. I have been able to successfully generate and display the next available number in the form and datasheet (using a query), but I can't make the value "stick." That is, I add a new record and "1234" appears in the field. I save the record. I add another new record. "1234" appears in that field, too, when it should be "1235." I have found that if I actually click in the field and then Save, the value does stick. However, this is not an intuitive workflow for my users. Any suggestions on how to resolve this issue are greatly appreciated.
What is the control source of these fields set to. Are they correctly set to the relevant fields?
Feb 8 '07 #3
NeoPa
32,557 Recognized Expert Moderator MVP
You'll need to test this, but I think this code may do the trick :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_AfterUpdate()
  2.   Call Me.Requery
  3. End Sub
The problem is due to the underlying recordset (of the form) not reflecting the extra record until a ReQuery is done.
Feb 8 '07 #4

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

Similar topics

4
1917
by: Stuart Palmer | last post by:
Hi everyone, I have a form with '/' in some of the field names, when I pass through to the next page the field name comes back as though it's been htmlencoded, so getting the value out of the...
3
1426
by: Jon Knutson | last post by:
I have a variable number of lines, with each line being a transaction, displayed in my jsp. Each line has an amount value with the name equal to the line it is displayed on. For example...
9
7116
by: Joanna Carter \(TeamB\) | last post by:
Hi folks I am trying to assign a Delegate to an Event using reflection. I use FieldInfo.GetValue to supposedly get the field object, but casting the result to the type of the field and...
2
1319
by: igendreau | last post by:
I have a database that I need to download tables into. My ODBC source takes way to long to report from, so I need to copy certain tables to an Access database, then I run my reports off that. ...
4
1162
by: telesphore4 | last post by:
Is there a better way to make the subclassing of built-in types stick? The goal is to have the the fields of a class behave like strings with extra methods attached. That is, I want the fact that...
2
1427
by: Stick | last post by:
I have defined to classes like this: namespace PanelColors.Helpers { public class PanelColor { public PanelColor() { r = 0; g = 0; b = 0; }
4
3642
by: bdockery | last post by:
Access 2007 I have a table with three columns. Country, State, City What I want to do is have a form where the Country, and State, lookups auto-populate when the city lookup is chosen. It...
2
2603
by: Kanashii | last post by:
First off - I want to thank all who respond / try to help out and even those who took a moment to read over my question. Please be patient as I am -very- new to VB in general and unfortunately...
5
1429
by: Arto Viitanen | last post by:
What is the best way to implement three value data, where the values are no/yes/not applicable ? I have used bool?, but I remember seeing some class (or most likely enum) on .net for this. --...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7123
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
7326
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,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3194
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1557
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.