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

After Update Event does not work.

Rozeanna Jerry
Hi Experts, am new to access. I juts created a form with sub form based on two tables having 1: many relationship.

The main form is from tblStudents and subform is from tble attendance.

First on main form I choose student name from a combo box and records for that student is displayed on the subform in form view.

1.*
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo14_AfterUpdate()
  2.     ' Find the record that matches the control.
  3.     Dim rs As Object
  4.  
  5.     Set rs = Me.Recordset.Clone
  6.     rs.FindFirst "[StudentID] = " & str(Nz(Me![Combo14], 0))
  7.     If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  8.  
  9.     DoCmd.GoToControl "Command12"
  10. End Sub  
The same
Ok now on the subform ( Form view) I have another combo to display records based on dates selected.

2*
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo12_AfterUpdate()
  2.     ' Find the record that matches the control.
  3.     Dim rs As Object
  4.  
  5.     Set rs = Me.Recordset.Clone
  6.     rs.FindFirst "[TimeSheetId] = " & str(Nz(Me![Combo12], 0))
  7.     If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  8. End Sub
Problem is that code#2 is not working..maybe because code one is filtering so code is refusing to filter as well. I do not know what to do.. ANy help will be appreciated.

Thanks

Rozeanna
Sep 22 '10 #1
14 3837
TheSmileyCoder
2,322 Expert Mod 2GB
Hi
I think your problem is that you need to enclose your result from the combobox in single quotes. Try looking at this Insight Article by NeoPa:
quotes & double quotes, where and when to use them

Here is the modified line of your code:
Expand|Select|Wrap|Line Numbers
  1. rs.FindFirst "[TimeSheetId] = '" & str(Nz(Me![Combo12], 0)) & "'"
Also this will help you in the future:
Debugging vba by NeoPa
Sep 22 '10 #2
Hi TheSmileyOne, Thanks for your assistance.
Replacing my code with your code gives this error message.

"Runtime Error 3464: Data mismatch in Criteria Expression"

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo12_AfterUpdate()
  2.     ' Find the record that matches the control.
  3.     Dim rs As Object
  4.  
  5.     Set rs = Me.Recordset.Clone
  6.    rs.FindFirst "[TimeSheetId] = '" & str(Nz(Me![Combo12], 0)) & "'"
  7.     If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  8. End Sub
Sep 23 '10 #3
Any ideas would be appreciated. Anyway thanks for the link.
Sep 23 '10 #4
My code#2 in post #1 works when I open the sub-form in it's own window. But does not work when I open the form with MAin+Subform. SO I was thinking that I would have the combo in main form and clone the subform recorset to find the selected record from combo. something like.



Expand|Select|Wrap|Line Numbers
  1.  Private Sub Combo12_AfterUpdate()
  2.    ' Find the record that matches the control.
  3.     Dim rs As Object
  4.  
  5.      Set rs = Me.Recordset.sub_form1.Clone
  6.      rs.FindFirst "[TimeSheetId] = " & str(Nz(Me![Combo12], 0))
  7.     If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  8.     End Sub
  9.  
Any help is appreciated.
Sep 23 '10 #5
TheSmileyCoder
2,322 Expert Mod 2GB
Did you look at the debuging article I linked?
Before the line that fails it would be a good idea to add:
Expand|Select|Wrap|Line Numbers
  1. Msgbox "[TimeSheetId] = " & str(Nz(Me![Combo12], 0))" 
so that you can verify that the criteria string is as expected.
Also I don't see a need for using your recordsetclone, but if you do, please explain. In my oppinion you could just do:

Expand|Select|Wrap|Line Numbers
  1. Me.RecordSet.FindFirst "[TimeSheetId] = " & str(Nz(Me![Combo12], 0)) 
then optionally do after:
Expand|Select|Wrap|Line Numbers
  1. If Me.Recordset.Nomatch Then msgbox "Record not found"
Sep 23 '10 #6
Expand|Select|Wrap|Line Numbers
  1.  Msgbox "[TimeSheetId] = " & str(Nz(Me![Combo12], 0))" 
is ok/fine.

However,
Expand|Select|Wrap|Line Numbers
  1. Me.RecordSet.FindFirst "[TimeSheetId] = " & str(Nz(Me![Combo12], 0)) 
  2.  
And
Expand|Select|Wrap|Line Numbers
  1. If Me.Recordset.Nomatch Then msgbox "Record not found"
Does not work in the Main/sub form but works perfectly in the sub-form in its own window. Any suggestion as to why this is happening? Obviously the sub-form doesn't want to work together with the main form; want to function individually on its own. Honestly am confused now..
Sep 24 '10 #7
Facts & Flash back: sub-form form is link to main form by studentID (Child and Parent keys).

Sub-form displays a filtered record based on a combo from Parent form. The problem arises on the second filter combo within the sub-form.
I was just thinking that filtering a filtered sub-form would pose that problem. Because if combo filtering is working in the sub-form's own window but not working within the parent-child form then maybe there maight be some other way of handling this. You guidance is highly require here.

Thanks so much.

Anna R.
Sep 24 '10 #8
TheSmileyCoder
2,322 Expert Mod 2GB
Using a combobox to select a record and then going to it like you do, is not actually filtering.

The only filtering is that a subform linked through StudentID, will of course only show records related to that Student. So the subform is filtered by the StudentID, and if you in your subform select a record which is not related to that Student, and want to go to it, then yes it will fail.

If I understand correctly:
Main form: Combobox select a student, and main form goes to that student.
Sub Form, Combobox 2 (within subform), select a timesheet and subform goes to that timesheet record? Please confirm

Do you remember to update the combobox of the subform to only show records for that student?


This is most certainly possible, I think we are just talking past each other. If you want you can upload the DB here, and I can take a look at it.
Sep 24 '10 #9
Jerry Maiapu
259 100+
Upload the db file or answer to post# 9 and maybe we could help.
Sep 26 '10 #10
If I understand correctly:
Main form: Combobox select a student, and main form goes to that student.
Sub Form, Combobox 2 (within subform), select a timesheet and subform goes to that timesheet record? Please confirm.


Hi, Thanks so much. What you presumed is 100% correct.
I could not upload the md file b'cause it's heavy..60MB. I'll try and delete some objects and send. AM so sorry for the late reply.
But if you tried to say something then mentioned so as what you guessed is correct.
TA.

Anna
Sep 26 '10 #11
TheSmileyCoder
2,322 Expert Mod 2GB
The easiest way to proceed with uploading a new database would be to create a new one, and then import from the original database the relevant forms/tables, and then just check that its working before uploading that new database. Also please answer my previous question.
Sep 26 '10 #12
Hi, am so sorry for the late reply. I was editing my existing db for confidentiality sake; do not what to publicise in forums like this. Anyway I came up with a similar db which is attached below. If you have spare time please have a look and reply.

**I was also thinking of just doing a search based on date entered on text box instead of combo but don know if that is possible.

A Bunch of Thanks!!

Anna
Attached Files
File Type: zip Sample.zip (36.6 KB, 105 views)
Sep 29 '10 #13
Hi TheSmileyOne, to your Question (POST#9), the subform is filtered by the StudentID, and the combo box in the subform select a record which is related to the Student, and therefore want to go to it. But Does not.

You understood me correctly:
Main form: Combobox select a student, and main form goes to that student.
Sub Form, Combobox 2 (within subform), select a timesheet (Date) and subform goes to that timesheet record. (The sample db has been attached for help like you requested)

Thanks Alot!

Anna
Oct 3 '10 #14
Mr Key
132 100+
Try this one also
Just browse to the link below, I have answered the similar question at the post named Record lookup with 2 Combo boxes
Oct 3 '10 #15

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

Similar topics

2
by: Johm | last post by:
I want to put one and same function under 2 controls in my subform. The controls are called quantity and cartons. Is it posible to build a code that recognizes the after update event of the...
3
by: David | last post by:
Hi I use a calendar to update a field and the after update event no longer works, if i manually update it there is not a problem. How can I get this event to trigger Thanks in advance Dave
6
by: Dugo | last post by:
I'm trying to use a "keypad" form (with command buttons for numbers 0 thru 9) I developed to allow users to first click a textbox on one form, then click a number on the keypad and have the value...
1
by: Tony | last post by:
Hi, In a form, when I modify some data and move to the next record, I want be able to trap an event and do a query to check on the change done to the table. Currently, I use the form After...
3
by: visionstate | last post by:
Hi All, I have put the following code in the 'After Update' of a combo box: Private Sub ComboTeam_AfterUpdate() lblSurnameNotify.Visible = True Me!ComboSurname = Null Me!ComboSurname.Requery...
1
by: Dave | last post by:
I'm having problems with certain fields that I force an update (Me.dirty=false) in the After Update Event I lose focus of the field where the user was or where he clicked help Is there a way...
4
by: Mikep99 | last post by:
I am new to access and need some help with coding. I have a main form XYZ with 2 subforms. I have a checkbox on subform1 "frmExpediteS" that when checked i would like the Value in Feild "PO" of this...
4
by: injanib via AccessMonster.com | last post by:
I have a combo box called "Recipient" who's row source is a table called "Main" with three columns. The three columns are "Name", "Floor", "Location". Following the combo box are two fields called...
26
kcdoell
by: kcdoell | last post by:
Hello: I have a continuous form that displays records. In the AfterUpdate event of one of the fields, Binding_Percentage, I have the following code: Private Sub...
5
by: Zeeshan7 | last post by:
After Update Event Procedure on a form is not working after upsizing database to SQL server. Anything to add in below code as it generate run time error 3622 "You must use the dbSeeChanges option...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.