[AccessD] Combo Subform Entries

Darren DICK d.dick at uws.edu.au
Tue Nov 18 18:57:20 CST 2003


Hi Virginia
Demo sent off line
If anyone wants a me too then make 'em to d.dick at uws.edu.au
Any me too's direct to this list will be ignored, snubbed and otherwise shown contempt :-)

See ya

Darren

----- Original Message ----- 
From: "Hollis,Virginia" <HollisVJ at pgdp.usec.com>
To: <accessd at databaseadvisors.com>
Sent: Wednesday, November 19, 2003 7:09 AM
Subject: [AccessD] Combo Subform Entries


> I have a combobox on a main form that is used to select certain records on
> the subform. For example, if you select Car from the combo, the subform
> shows all the records for Car.
>  
> I need to be able to add an entry to the combobox on the main form & have it
> available for use to add new records. So if I add Jeep to the NotInList
> event of the combobox, Jeep would be in the list, the Combo would show Jeep,
> & the subform should be blank & ready to add new entries for Jeep.
>  
> I tried Requery, I tried a seperate form for adding new entries to the list,
> and OnClose of the form, requery the form, but nothing works. The entry is
> in the list, but the subform stays on the previous selections entry. Or
> should the requery go on the After Update of the Combo?
>  
> Virginia
>  
> On NotInList
>  
>     ' Return Control object that points to combo box.
>     Set ctl = Me!cboLocation
>     ' Prompt user to verify they wish to add new value.
>     If MsgBox("Would you like to add '" & NewData & "' to the list?",
> vbYesNo, "Add New Name") = vbYes Then
>         ' Set Response argument to indicate that data is being added.
>         Response = acDataErrAdded
>         ' Add string in NewData argument to table.
>         NewData = DoConv(NewData)
>         strSQL = " INSERT INTO tbl_Location ( Location ) SELECT '" &
> DoConv(NewData) & "'"
>         DoCmd.SetWarnings False
>         DoCmd.RunSQL strSQL
>         ctl.Value = NewData
>         DoCmd.SetWarnings True
>    
>     Else
>         ' If user chooses Cancel, suppress error message and undo changes.
>         Response = acDataErrContinue
>         ctl.Undo
>     End If
> 
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com


More information about the AccessD mailing list