Newsgroup: it.comp.appl.access
Titolo: OT Traduzione FAQ 4.13

*********************
4.13 Combo Box - Add a new record
Problem
You want to add a new record to a combo box.
Solution
Variant 1
The user types in a new value. You want to take it over to
the rowsource of the combo without asking. So you have to
- sort the combo after the field that gets inserted
- set the property "Limit to list" to True
- use the following code at the "Not in list" event of the combo
'************** CODE START **************
Response = acDataErrAdded
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("TableName", dbOpenDynaset)
rs.AddNew
rs!FieldName = NewData
rs.Update
rs.Close : Set rs = Nothing
Set db = Nothing
'************** CODE END **************
Variant 2
Let's say you have a form "frm_Invoice" with a combo box
"cbo_SearchClient" (bound column is "ClientId").
If the user types in a new value into the combo you first
want to ask him, then open an input form ("frm_NewClient"),
take over the typed in client name and maybe let the user add
further data in the input form. After closing the input form
the combo shall show the new value. To accomplish this use
the following code at the event "Not in list" of the combo:
'************** CODE START **************
If MsgBox("This client is new. Do you want to create a new record?", _
                  vbYesNo) = vbYes
Then
    Response = acDataErrContinue
    DoCmd.OpenForm "frm_NewClient", , , , acFormAdd
    Forms!frm_NewClient!ClientName = NewData
Else  'e.g. in case of a typing error
    Response = acDataErrContinue
    Me!cbo_SearchClient.Undo
End If
'************** CODE END **************
At the event "OnClose" of the input form:
Forms!frm_Invoice!cbo_SearchClient = Me!ClientId
Forms!frm_Invoice!cbo_SearchClient.Requery
*******************
-- 
cu
Karl
*********
Access FAQ: 
www.donkarl.com/it
 

 the following code at the event "Not in list" of the combo:
2^ variante
Supponiamo che tu abbia una maschera "frm_Fatture" con una casella combinata
"cbo_RicercaCliente" (la colonna associata è IDcliente).
Se l'utente scrive nella casella un nuovo valore che non è presente
nell'elenco si vuole prima chiedere conferma, e poi aprire una maschera di
inserimento dati ("frm_NuovoCliente"), recuperare il nuovo nome cliente già
digitato ed eventualmente lasciare che l'utente aggiunga ulteriori dati
tramite la maschera. Alla chiusura della maschera la casella combinata dovrà
mostrare il nuovo valore.
Per fare ciò usa il seguente codice nella routine evento "Su non in elenco"
della casella:
'************** INIZIO DEL CODICE **************
If MsgBox("Questo cliente è nuovo. Lo vuoi aggiungere alla tabella
clienti?", _
                  vbYesNo) = vbYes
Then
    Response = acDataErrContinue
    DoCmd.OpenForm "frm_NuovoCliente", , , , acFormAdd
    Forms!frm_NuovoCliente!NomeCliente = NewData
Else  'in caso di errore di digitazione:
    Response = acDataErrContinue
    Me!cbo_RicercaCliente.Undo
End If
'************** FINE DEL CODICE **************
Sull'evento "Su Chiusura" della maschera di inserimento dati:
Forms!frm_Fatture!cbo_RicercaCliente = Me!IDcliente
Forms!frm_Fatture!cbo_RicercaCliente.Requery
*******************

with compromising
photographs. If one goes to New Orleans, one will still meet
those who say that Jim Garrison indicted Clay Shaw because he was
himself gay and jealous of Shaw's position in the homosexual
underworld. And we all know how the FBI tried to drive King to
suicide by blackmailing him with clandestinely made "sex tapes."
The Church Committee
What precipitated these posthumous and personal attacks on the
Kennedys? Something happened in the seventies that necessitated
the "second assassination" from the right - i.e. the use of
scandal to stamp out Kennedy's reputation and legacy. That
something was the Church Committee. Belated revelations about the
CIA's role in Watergate, and later of the CIA's illegal domestic
operations created a critical firestorm demanding a full-scale
investigation of the CIA. The fallout from Watergate had produced
large Democratic majorities in both houses of congress via the
1974 elections. This majority, combined with some of the moderate
Republicans, managed to form special congressional committees.
The committee in the Senate was headed by Idaho's Frank Church.
Other leading lights on that committee were Minnesota's Walter
Mondale, Colorado's Gary Hart, Tennessee's Howard Baker, and
Pennsylvania's Richard Schweiker.
As writers Kate Olmsted and Loch Johnson have shown, the Church
Committee was obstructed by two of the CIA's most potent allies:
the major media and friendly public figures. In the latter
category, Olmsted especially highlights the deadly role of Henry
Kissinger. But as Victor Marchetti revealed to me, there was also
something else at work behind the scenes. In an interview in his
son's office in 1993, Marchetti told me that he never really
thought the Agency was in danger at th

for Giancana.
And if RFK was working with Sam, then maybe Bobby unwittingly had
his brother killed. Tragic, but hey, if you play with fire you
get burned. Tsk. Tsk.
But beyond this, there is an even larger gestalt. If the Kennedys
were just Sorenson-wrapped mobsters or CIA officers, then what
difference does it make in history if they were assassinated? The
only people who should care are sentimental Camelot sops like
O'Donnell and Powers who were in it for a buck anyway. Why waste
the time and effort of a new investigation on that. For the CIA,
this is as good as a rerun of the Warren Commission, since the
net results are quite similar. So its no surprise to me that the
focus of Hersh's book has shifted between Oswald did it for the
Mob, and an all out trashing of the Kennedys.
The standard defense by these purveyors is that they go on the
offense. Anyone who objects to their peculiar blend of
misinformation, or questions their sources or intent is labeled
as "protecting the Kennedys," or a "disappointed Kennedy fan," or
a "hagiographer." Tactically, this is a great cover

 Variant 2



4.13 Casella combinata – Aggiungere un nuovo record
Problema
Vuoi aggiungere un nuovo record ad una casella combinata (combo box).
Soluzione
Variante 1
L’utente inserisce un nuovo valore. Tu lo vuoi acquisire nell’origine
della casella combinata senza alcuna domanda. In questo caso devi:
- ordinare la casella dopo che il campo ha avuto l'inserimento
- impostare la proprieta "Solo in elenco" a Sì
- utilizzare il seguente codice nell’evento “ Su non in elenco” della combo
'************** INIZIO CODICE **************
Response = acDataErrAdded
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("NomeTabella", dbOpenDynaset)
rs.AddNew
rs!FieldName = NewData
rs.Update
rs.Close : Set rs = Nothing
Set db = Nothing
'************** FINE CODICE **************
Variante 2
Diciamo che tu hai una maschera "frm_Fattura" con una combo
"cbo_RicercaClienti" (la colonna associata è "ClienteId").
Se l’utente digita un nuovo valore nella combo tu prima glielo chiedi, poi
apri una maschera di inserimento dati ("frm_NuovoCliente"),
acquisisci il nome del (nuovo) cliente e permetti che l’utente aggiunga
ulteriori dati nella maschera di inserimento. Dopo la chiusura della
maschera la combo mostrerà il nuovo valore. Per raggiungere ciò utilizza
il seguente codice nell’evento "Su non in elenco" della combo:
'************** INIZIO CODICE **************
If MsgBox("Questo è un nuovo cliente. Vuoi creare un nuovo record?", _
vbYesNo) = vbYes
Then
Response = acDataErrContinue
DoCmd.OpenForm "frm_NuovoCliente", , , , acFormAdd
Forms!frm_NuovoCliente!NomeCliente = NewData
Else 'p.e. nel caso di un errore di digitazione
Response = acDataErrContinue
Me!cbo_SearchClient.Undo
End If
'************** FINE CODICE **************
Nell’evento "Su chiusura" della maschera di inserimento:
Forms!frm_Invoice!cbo_RicercaCliente = Me!ClientId
Forms!frm_Invoice!cbo_RicercaCliente.Requery
--
rgrds
SC
-- 
questo articolo e` stato inviato via web dal servizio gratuito 
http://www.newsland.it/news
 segnala gli abusi ad 
ab...@newsland.it

Karl Donaubauer ha scritto:
<cut>
Nella colonna "Tema" della home page si legge al riguardo della FAQ 4
"11" ma le FAQ sono 12.


 Ciao Karl,
ho provato la seconda soluzione ed è eccezionale, BRAVO !!
Ciao.