473,486 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

combo box after update event

86 New Member
i have this code in a combo box after update event.

what it's supposed to do is open the User Problem Log form and go to the specific record.

I have this combo box on another form.
trouble no is the autonumber and that's what is used to go to that specific record on the User Problem Log form.

Expand|Select|Wrap|Line Numbers
  1.     DoCmd.OpenForm ("User Problem Log")
  2.  
  3.     Dim rs As Object
  4.  
  5.     Set rs = Me.Recordset.Clone
  6.  
  7.     [Forms]![User Problem Log]![trouble_no] = " & Str(Nz(Me![Combo5], 0))"
  8.  
  9.     If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  10.  
this is similar to the "Jump To" where it goes to that specific record. however, somehow this is not working.

i am getting an error code:
"Run-time error '2113':
The value you entered isn't valid for this field."

and then it breaks to this line of code
Expand|Select|Wrap|Line Numbers
  1. [Forms]![User Problem Log]![trouble_no] = " & Str(Nz(Me![Combo5], 0))"
thanks!
Jul 22 '11 #1
6 3289
Jeffrey Tan
86 New Member
This part only opens the form, but does not go to that record

Expand|Select|Wrap|Line Numbers
  1.     Dim rs As Object
  2.  
  3.     DoCmd.OpenForm ("User Problem Log")
  4.  
  5.     Set rs = [Forms]![User Problem Log].Recordset.Clone
  6.  
  7.     rs.FindFirst "[trouble_no] = " & Str(Nz(Me![Combo5], 0))
Jul 22 '11 #2
NeoPa
32,556 Recognized Expert Moderator MVP
I would suggest using :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.OpenForm("User Problem Log")
  2. With Forms("User Problem Log").Recordset
  3.   If Not IsNull(Me.Combo5) Then Call .FindFirst("[Trouble_No]=" & Me.Combo5)
  4. End With
Jul 23 '11 #3
Jeffrey Tan
86 New Member
Thanks neopa.. forgot to update this thread yesterday.

i was thinking correctly

it was actually a pretty easy one.

i used

Expand|Select|Wrap|Line Numbers
  1. DoCmd.Open Form("User Problem Log")
  2. [Forms]![User Problem Log]![Combo74].Text = Str(Nz(Me![Combo5], 0))
  3.  
and that basically solved it.

i was a bit worried that it wouldn't work but i guess the Combo74.Text (from user problem log) sets the text and also goes to the specific record based on the after update for my combo5.
Jul 23 '11 #4
ADezii
8,834 Recognized Expert Expert
Here is another approach you can take that will Filter for the specified [Trouble_No], as well as check for its existence:
Expand|Select|Wrap|Line Numbers
  1. If IsNull(Me![Combo5]) Then
  2.   Exit Sub
  3. 'Does a Record even exist for the [Trouble_No]?
  4. ElseIf DCount("*", "Employees", "[<Data Source for Form>] = " & Me![Combo5]) = 0 Then
  5.   MsgBox "No Records match specified Criteria", vbExclamation
  6. Else        'All is well, Open the Form for the [specified Trouble_No]
  7.   DoCmd.OpenForm "User Problem Log", acNormal, , "[Trouble_No]= " & Me![Combo5], acFormEdit
  8. End If
Jul 23 '11 #5
Jeffrey Tan
86 New Member
@ADezii :)

Thanks. it should work 100% with no problem because the query for Combo5 comes directly from the user problem log table (main table) so anything in combo5 is valid :P

Thanks again.
Jul 23 '11 #6
NeoPa
32,556 Recognized Expert Moderator MVP
Well, if that works then fine Jeffrey. It includes elements and concepts that aren't mentioned in the question, so not something anyone could have helped with, but if you're happy then we can move on ;-)
Jul 23 '11 #7

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

Similar topics

1
2939
by: Jason | last post by:
I have a main form with a sub form. All the fields in the subform are mandatory. I had some code on the main form Before Update Event to check if all the fields in the sub form have data. If not, I...
3
3933
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
1
2520
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
1914
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...
8
4075
by: Michael R | last post by:
Dear users and experts, An unbound combo box in my form is responsible for changing a city name for an update query that creates a temprorary table which the form uses as its record source. In...
4
5616
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...
33
5483
by: buss123 | last post by:
Hi all, combo box script code was working in IE perfectly with all modes but OnChange event was not working in FireFox(editable mode, if we select valuese that combo box values r...
4
5803
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...
5
2831
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...
14
3838
Rozeanna Jerry
by: Rozeanna Jerry | last post by:
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...
0
7099
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
6964
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
7123
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
7175
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
4559
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
3069
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
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
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
262
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.