473,761 Members | 9,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Combo box after update event

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 "Floor" and "Location". The
after update event of the combo box runs the following lines to update the
next two fields.

[Floor] = Recipient.Colum n(2)
[Location] = Recipient.Colum n(3)

The combo box is not limited to the values in its rowsource table. What I
want is that if the value entered in the combo box is not in its rowsource it
should update the next two fields as follows.

[Floor] = "1"
[Location] = "?"

I tried the following code and it gives me the error "You canceled the
previous operation".

if DCount("*", "Main", "[Name]=" & me.Recipient)< 1 then
[Floor]="1"
[Location]="?"
else
[Floor] = Recipient.Colum n(2)
[Location] = Recipient.Colum n(3)
end if.

--
Message posted via http://www.accessmonster.com

Aug 28 '07 #1
4 5824
ARC
Do you have an add/edit form that allows changes to the table that stores
Name/Floor/Location? If so, you could just do a not in list event that opens
the add/edit form to a new record. Something like:

Private Sub SalesInitID_Not InList(NewData As String, Response As Integer)
If MsgBox("The Sales Person Initials you entered could not be found. Would
you like to add it now?", vbYesNo + vbInformation, "Item Not Found - Add?")
= vbYes Then
DoCmd.OpenForm "SalesInitials" , , , , acFormAdd
Forms!SalesInit ials.Form!Sales Initials = NewData
End If
Response = acDataErrContin ue
Me!SalesInitID. Undo
DoCmd.CancelEve nt
End Sub
Aug 28 '07 #2
On Aug 28, 3:55 pm, "injanib via AccessMonster.c om" <u35551@uwe>
wrote:
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 "Floor" and "Location". The
after update event of the combo box runs the following lines to update the
next two fields.

[Floor] = Recipient.Colum n(2)
[Location] = Recipient.Colum n(3)

The combo box is not limited to the values in its rowsource table. What I
want is that if the value entered in the combo box is not in its rowsource it
should update the next two fields as follows.

[Floor] = "1"
[Location] = "?"

I tried the following code and it gives me the error "You canceled the
previous operation".

if DCount("*", "Main", "[Name]=" & me.Recipient)< 1 then
[Floor]="1"
[Location]="?"
else
[Floor] = Recipient.Colum n(2)
[Location] = Recipient.Colum n(3)
end if.

--
Message posted viahttp://www.accessmonst er.com
Insure the "Limit to list" property for Recipient is True then:

Private Sub Recipient_NotIn List(NewData As String, Response As
Integer)
Me.Floor.Value = "1"
Me.Location.Val ue = "?"
Response = acDataErrContin ue
End Sub

You'll have to add some if you then want the updated fields to be
added to the drop-down list or add them to the table.

Aug 29 '07 #3
this works, but I can not make the focus to leave Recipient field. Not even
by clicking else where.

DTecMeister wrote:
>On Aug 28, 3:55 pm, "injanib via AccessMonster.c om" <u35551@uwe>
wrote:
>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".
[quoted text clipped - 25 lines]
>--
Message posted viahttp://www.accessmonst er.com

Insure the "Limit to list" property for Recipient is True then:

Private Sub Recipient_NotIn List(NewData As String, Response As
Integer)
Me.Floor.Val ue = "1"
Me.Location.Va lue = "?"
Response = acDataErrContin ue
End Sub

You'll have to add some if you then want the updated fields to be
added to the drop-down list or add them to the table.
--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200708/1

Aug 29 '07 #4
On Aug 29, 9:38 am, "injanib via AccessMonster.c om" <u35551@uwe>
wrote:
this works, but I can not make the focus to leave Recipient field. Not even
by clicking else where.

DTecMeisterwrot e:
On Aug 28, 3:55 pm, "injanib via AccessMonster.c om" <u35551@uwe>
wrote:
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".
[quoted text clipped - 25 lines]
--
Message posted viahttp://www.accessmonst er.com
Insure the "Limit to list" property for Recipient is True then:
Private Sub Recipient_NotIn List(NewData As String, Response As
Integer)
Me.Floor.Value = "1"
Me.Location.Val ue = "?"
Response = acDataErrContin ue
End Sub
You'll have to add some if you then want the updated fields to be
added to the drop-down list or add them to the table.

--
Message posted via AccessMonster.c omhttp://www.accessmonst er.com/Uwe/Forums.aspx/databases-ms-access/2007...- Hide quoted text -

- Show quoted text -
I got it. You'll need to programmaticall y add the new row to the
table containing the rowsource information and set the fields with
default values:
Dim MyConnection As New ADODB.Connectio n
Dim AddSQL As New ADODB.Command
MyConnection.Op en "DSN=Set_Me_to_ your_ODBCCONNEC TION"
MyConnection.Cu rsorLocation = adUseClient
Set AddSQL.ActiveCo nnection = MyConnection
AddSQL.CommandT ext = "insert into Recipients values ('" + NewData +
"',''1,'?') "
AddSQL.Execute
Response = acDataErrAdded

I use linked tables so you may be able to do this without the odbc
connection, but you get the idea.

Aug 31 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5428
by: OhFiddleSticks | last post by:
Does anyone know if there is a way to add a text value to a combo box (the text box part, not the rowsource) in VBA without triggering an update event? I've tried everything I can think of without success. What I want is a combo box that I set the rowsource for in VBA and requery it, then it drops down, and enters a probable selection that may or may not already be in the list to the text box portion. Then I can manually compare the...
1
2338
by: Maria Joao | last post by:
I have two synchronized combo boxes and after the selection of the desired record, I need the user to open the related report, by pressing a button. My problem is that a combo box doesn't update do the first one. The record are correct, but the first one is always from the last selection. How can I update the second combo box? Thanks
6
3555
by: Support4John | last post by:
a2k (9.0.6926) SP-3 Jet 4.0 SP-7 I have a form with combo box field that allows the user to select from the combo box or type in the field value that may or maynot be in the combo box field. In the After Update Event of the combo box field how can I tell if the field value was selected from open combo box or typed in by the user? Thanks, John
11
2804
by: my-wings | last post by:
I think I've painted myself into a corner, and I'm hoping someone can help me out. I have a table of books (tblBooks), which includes a field (strPubName) for Publisher Name and another field (strPubCity) for Publisher City. These two fields have a many-to-one relationship with tables, (tlkpPubName and tlkpPubCity) respectively. The lookup tables only have one field (strPubName and strPubCity), which is their primary key. I also have...
9
32626
by: Vmusic | last post by:
Hi, I'm using MS Access 2002. I have a form with a combo box built from a query that returns one column, and that one column is the bound column. How do you use VBA to programmatically change which row in the combo box is selected?? I looked at the forum and the answers aren't very clear. Of course the MS Access help file is worthless.
5
2736
by: debbie | last post by:
I have three combo boxes on a subform. I have tried setting them up so that when the user clicks in the combo box the curser moves to the left. I have searched the posts and can find nothing that answers my problem....no matter what I have tried....on click, set focus, got focus...one combo box works and the other two start one space from the left....now if the user tabs, of course they all work...and if you've clicked anywhere else on...
4
64631
Rabbit
by: Rabbit | last post by:
Cascading Combo/List Boxes This tutorial is to guide you in the creation of Cascading combo/list boxes. That is when you have multiple combo/list boxes where the selection of an option in one determines the available options in the other. TERMINOLOGY Row Source: The table/query from which the Combo Box or List Box gets its values. Note: There are other types of row sources that can be used but for simplicity we will stick with Tables...
6
3682
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
12
2144
by: Richard Penfold | last post by:
I have a form with a subform containing the combo box I want to update. I have a command button in the header of the main form that launches a report in print preview mode. I want to update the combo box from 'New' to 'Confirmed' when the report is generated. I have tried the following code in both the buttons on_click event and in the reports on_close event (security is set to trust the db) Forms!!.!="1" There are no errors but it does...
0
9554
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9376
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9811
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8813
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7358
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5266
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3911
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 we have to send another system

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.