473,385 Members | 2,029 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,385 software developers and data experts.

Data is changing that shouldnt

truthlover
107 100+
I am having a very perplexing problem that I'm hoping someone can help me solve. It's a little difficult to explain, but I'll do my best. I'm also providing a link to the file so you can take a closer look.

What I have is a form that is used to enter details of time spent on a job, the rate of the task and who performed the task. The form allows the user to choose the project they want to provide details for with a subform where the details are actually entered/edited. There is a button on the form that allows the user to print a summary of the details.

Up until now, everything seemed to be working fine. But the other day, the person maintaining this process deleted a record. The record he deleted was deleted with no problem, but somehow, when the record was deleted for Project 08.0136.01, a record for Project 08.0126.01 somehow had the project number changed to Project 08.0136.01.

It doesnt seem to happen when a record from 08.0126.01 is deleted because there are no records in the table after it (though I'm sure if the table was re-sorted to put those records first, but same thing would happen).

I thought it might have to do with the subform referencing a query instead of the table, so I changed the source to the table, and the same thing happened.

For the life of me, I cannot figure out how that could happen or how to fix it. If anyone can help, I'd be most grateful. Here's the link to the file http://www.stellarwebcreations.com/C...ataProblem.zip.

The form in question is frm_EditConstructionLog. If you choose project 08.0136.01 from the dropdown and delete one of the records, you'll see what I'm tryin to explain. The simplest way to see the problem is to run the "Print Construction Log" You'll see the totals do not add up to what they should if just the one record was deleted, and the record that had the number changed will appear in Project 08.0136.01.

BTW I'm using Access 2002 to create the database but it is saved in 2000 format.

Thanks so much!
May 15 '08 #1
17 1479
Well there is no code behind to combo box so you can't select 136 and how are you deleting records you have not option or button. It looks like your using the link child and master fields property. I've never liked using them and always recommend you move that restriction over to the queries. I can see that this is a chopped down version of your DB since frm_menu is not there. so maybe so other things are missing as well. in order to give you any help at all I would need to no how you are going about deleting the record. please post code.
May 15 '08 #2
truthlover
107 100+
Well there is no code behind to combo box so you can't select 136
Not sure what you mean. I just opened the file (yes, it is cut down) and there is a combo box right above the subform (label = Choose Project Number) If you go into the properties of that box, you will see where it is pulling the data from.

in order to give you any help at all I would need to no how you are going about deleting the record. please post code.
The records are being deleted directly from the sub form (just clicking on the record selector and deleting the record)

Thanks!
May 15 '08 #3
Wups my fault I was having issue because I was in read only mode I had to use IE because FF would not let me download your file however I'm not seeing the same issue as you, however when I deleted multiple records in a row I experienced what is called stepping on a record, this is because your not forcing a save after delete. I think the issue is just because your basically allowing the user to edit the table directly however they want the form is not locked down. I sorry I can't really help personally I wold have a different form for the user to edit delete and add records instead of using the data sheet.
May 15 '08 #4
truthlover
107 100+
I'm not seeing the same issue as you, however when I deleted multiple records in a row I experienced what is called stepping on a record, this is because your not forcing a save after delete.
You have to delete a record from Project 08.136.01 to see it happen. Can you explain "stepping on a record"?

I think the issue is just because your basically allowing the user to edit the table directly however they want the form is not locked down. I sorry I can't really help personally I wold have a different form for the user to edit delete and add records instead of using the data sheet.
Yes, i'm sure the way the form is constructed is the root of the problem, but I havent been able to come up with a way to prevent the errors in its current state or create an alternate solution that would allow the user to choose the project they want to edit AND have a view of all the records for that project.

A Continuous view form seemed like the best solution, but I couldnt figure out how to get the dropdown to filter the way the current form is working.

I'm sure there's a way, I'm just not sure what that is. I'm good with Access basics, but when it comes to issues like these, I need help. I also dont know VBA yet, so I dont have that knowledge to draw on.

So if you can suggest a better method of accomplishing my goals, I'd love to hear about it.

Thanks!
May 15 '08 #5
Well I do have something similar in one of my DBs but instead of allowing them to edit the record on the data sheet I created another sub form that they add edit and delete the records from, what i do is put a click event on all of the fields in the datasheet and use code like this
Expand|Select|Wrap|Line Numbers
  1.     Dim rs As Object
  2.     Forms!Order_Quote!Edit_Detail.Requery
  3.     Set rs = Forms!Order_Quote!Edit_Detail.Form.Recordset.Clone
  4.     rs.FindFirst "[OI_ID] = " & Me.OI_ID
  5.     If Not rs.EOF Then Forms!Order_Quote!Edit_Detail.Form.Bookmark = rs.Bookmark
  6.     Forms!Order_Quote!Edit_Detail.Form.Refresh
it's kind of a weird way to do things but it works.

to explain the code a little better
first you have the (dim rs as object) this is needed so access knows what you mean by rs

then we re query the new sub form this is optional so we refer to ( Forms!The name of the form your on!the name of your new subform.form.requery ) this will force the query behind the form to refresh itself

then you'll notice that you refer to the new sub form again the same as before but this time it's (Set rs bla bla bla.form.recordset.clone

then you find the record you want ( were you see OI_ID just insert the field name of your PK or whatever you use to identify the records.

the rest should be self explanatory let me know if it helps
May 15 '08 #6
truthlover
107 100+
Well I do have something similar in one of my DBs but instead of allowing them to edit the record on the data sheet I created another sub form that they add edit and delete the records from, what i do is put a click event on all of the fields in the datasheet and use code like this
Expand|Select|Wrap|Line Numbers
  1.  Dim rs As Object
  2. Forms!Order_Quote!Edit_Detail.Requery
  3. Set rs = Forms!Order_Quote!Edit_Detail.Form.Recordset.Clone
  4. rs.FindFirst "[OI_ID] = " & Me.OI_ID
  5. If Not rs.EOF Then Forms!Order_Quote!Edit_Detail.Form.Bookmark = rs.Bookmark
  6. Forms!Order_Quote!Edit_Detail.Form.Refresh
it's kind of a weird way to do things but it works.

to explain the code a little better
first you have the (dim rs as object) this is needed so access knows what you mean by rs

then we re query the new sub form this is optional so we refer to ( Forms!The name of the form your on!the name of your new subform.form.requery ) this will force the query behind the form to refresh itself

then you'll notice that you refer to the new sub form again the same as before but this time it's (Set rs bla bla bla.form.recordset.clone

then you find the record you want ( were you see OI_ID just insert the field name of your PK or whatever you use to identify the records.

the rest should be self explanatory let me know if it helps
I got the gist of what you were saying, but the rest may as well be in another language. That's the problem with not knowing VBA -- even the simplest instructions are confusing.

At any rate, I've found a suitable solution for the moment.

However if you (or anyone else out there) can tell me how to get a dropdown combo box to pull up specific records, I'd be so grateful.

Thanks for your help!
May 15 '08 #7
when you go to create a combo or list box it gives you 3 options chose the last one something like "find a record record on your form based on what I selected from my combo box" and it will take you through a wizard.

The code i just gave was pulled from behind a combo box and modified to do what I told it to. But if you go through the wizard like i said access will create the code for you.

you really can't do anything in Access without VB6 so I highly recommend you pick up a book and start to learn I picked up the just of it in about 2 weeks and you just kind of keep learning new tricks from there.
May 15 '08 #8
truthlover
107 100+
when you go to create a combo or list box it gives you 3 options chose the last one something like "find a record record on your form based on what I selected from my combo box" and it will take you through a wizard.

The code i just gave was pulled from behind a combo box and modified to do what I told it to. But if you go through the wizard like i said access will create the code for you.

you really can't do anything in Access without VB6 so I highly recommend you pick up a book and start to learn I picked up the just of it in about 2 weeks and you just kind of keep learning new tricks from there.
I'll give that a try, thanks.

As for learning VBA, i've just recently started reading a pretty good book (I've already solved a few problems with the little I've learned) Problem is I've got so little time to read it (working 3 jobs and the gaps between my time reading make it harder to retain) but I am learning. Now if only the issues with the db I'm working with would be so kind as to not show up until I've learned more ;)

But until then, I'm very grateful for your help and the help of everyone else in this forum. I couldnt do it without you!

Thanks!
May 16 '08 #9
truthlover
107 100+
I'll give that a try, thanks.
Ok, I just tried the combo box and it didnt work the way I need it to work.

I'm using a Continuous view form, and I need a combo box to filter the results.

Got any ideas how to do this with a dropdown?

Thanks!
May 16 '08 #10
NeoPa
32,556 Expert Mod 16PB
You could try looking at Example Filtering on a Form. Let us know how you get on with it.
May 21 '08 #11
truthlover
107 100+
Ok, I tried doing this. I shortened the code since all I need is the combo box. I also set the source code for the combo box to a query list of the available project numbers (rather than a value list the way the zip file has it set as)

Expand|Select|Wrap|Line Numbers
  1. 'CheckFilter produces the new Filter depending on the values currently in cboFindAccountType.
  2. Private Sub CheckFilter()
  3. Dim strFilter As String, strOldFilter As String
  4. strOldFilter = Me.Filter
  5. 'cboChooseProjectNumber - Numeric
  6. If Me!cboChooseProjectNumber > "" Then _
  7. strFilter = strFilter & _
  8. " AND ([ProjectID]=" & _
  9. Me!cboChooseProjectNumber & ")"
  10. 'Debug.Print ".Filter = '" & strOldFilter & "' - ";
  11. 'Debug.Print "strFilter = '" & strFilter & " '"
  12. 'Tidy up results and apply IF NECESSARY
  13. If strFilter > "" Then strFilter = Mid(strFilter, 6)
  14. If strFilter <> strOldFilter Then
  15. Me.Filter = strFilter
  16. Me.FilterOn = (strFilter > "")
  17. End If
  18. End Sub
  19.  

But when I run it, I get this:
runtime error #3075

syntax error in number in query expression
'([ProjectID=08.0136.01)'

When I do the debug, it highlights line 15 (but I dont know how to fix it)


Any suggestions?

Thanks!!

You could try looking at Example Filtering on a Form. Let us know how you get on with it.
May 21 '08 #12
Stewart Ross
2,545 Expert Mod 2GB
Hi truthlover. Your filter expression is not correctly-formed. You are referring to the [project ID] field as a number, not a string, by missing single quotes out. Lines 8 and 9 should be
Expand|Select|Wrap|Line Numbers
  1. " AND ([ProjectID] = '" & Me.cboChooseProjectNumber & "')"
-Stewart
May 21 '08 #13
NeoPa
32,556 Expert Mod 16PB
Nice catch Stewart :)

@TruthLover - That was a fair attempt at implementing the logic from the article.
I'm curious though, why you dropped the code indentation. Properly indented code can be so much easier to read and understand. Was this an accidental by-product of your preparation of the post perhaps?
May 22 '08 #14
truthlover
107 100+
Hi truthlover. Your filter expression is not correctly-formed. You are referring to the [project ID] field as a number, not a string, by missing single quotes out. Lines 8 and 9 should be
Expand|Select|Wrap|Line Numbers
  1. " AND ([ProjectID] = '" & Me.cboChooseProjectNumber & "')"
-Stewart
Yes, the ProjectID is a string. I didnt change the notes (that referred it to a number) but I had a feeling the fact that it was a string was the problem (I just didnt know how to make the correction).

I'll give it a try and get back to you.

Thanks!
May 22 '08 #15
truthlover
107 100+
Nice catch Stewart :)

@TruthLover - That was a fair attempt at implementing the logic from the article.
I'm curious though, why you dropped the code indentation. Properly indented code can be so much easier to read and understand. Was this an accidental by-product of your preparation of the post perhaps?
Thanks Neo

I didnt drop the indents, though. I just copy/pasted and that was the results. I couldnt remember how to code the code for vb instead of text. Guess I should have reinserted the indents to make it easier to read.

Thanks
May 22 '08 #16
truthlover
107 100+
Yes, the ProjectID is a string. I didnt change the notes (that referred it to a number) but I had a feeling the fact that it was a string was the problem (I just didnt know how to make the correction).

I'll give it a try and get back to you.

Thanks!
It worked great, thanks!!!! You made my week :)
May 22 '08 #17
NeoPa
32,556 Expert Mod 16PB
Normally the VB code is done as "[ CODE=VB ]" (No spaces or quotes). It's not working at the moment as there were too many issues with the libraries used for this. We're currently looking for replacements.

No worries about the indenting. I was only really interested if you'd decided explicitly to remove them.

PS. Glad you got it working ;)
May 22 '08 #18

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

Similar topics

2
by: Neo | last post by:
can anybody help me in writing a javascript function which opens a popup window with the target URL when the link "POST Request" is clicked.. Points to note: The HTML DOESNT and SHOULDNT...
4
by: Thomas Paul Diffenbach | last post by:
Can anyone point me to an open source library of /statically allocated/ data structures? I'm writing some code that would benefit from trees, preferably self balancing, but on an embedded system...
13
by: Ian Davies | last post by:
Im trying to test if two fields have been entered at the same time I have tried many combinations but cant get it. My last effort was if(isset($_POST && isset($_POST)){ die('You can\'t select...
2
by: dkoco | last post by:
I have a C#.Net program that once a button is clicked it goes to a public class(called Tal) and gets data in a vector, then exits the class, and goes back to the main form(program). I will do this...
1
by: xamman | last post by:
hi there, i am busy coding a fix for Santa's package labelling system. i have come across some wierd behaviour with enableViewStateMac on this server. this web has a page a.aspx with a textbox...
3
sumaiya
by: sumaiya | last post by:
When a user submits a form and clicks on the back button how can he view his already entered data?? I really need to knw this. I mean the user shouldnt loose his data if he encounters an error...
4
by: slinky | last post by:
I have a textbox that a user enters the current time (in this case at the end of a task, and it gets its value via a button's click event and getting its value from =Now() ). Is there a way to...
4
by: junkmate | last post by:
I am making an RSS parser that takes multiple XML inputs in to an array and then sorts them by their date value... and it 'almost' works... I always lose the top value of the second rss feed to be...
3
by: jacob navia | last post by:
Abstract: Continuing the discussion about abstract data types, in this discussion group, a string collection data type is presented, patterned after the collection in C# and similar languages...
0
ADezii
by: ADezii | last post by:
Rather than using CurrentProject.Connection or entering your own Connection information, ADO supports storing Connection information in an external file called a Data Link File (which normally has a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.