Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to immediately populate field on subform from a combo box?

Status
Not open for further replies.

snowyej

Technical User
Nov 26, 2001
69
US
Hi!

Two questions.

I have a form with a subform in it. The form basically allows us to track software on a specific machine. On the main form is a combo box with a list of applications. There are two command buttons: ADD and REMOVE. In the subform is the list of applications for the specific machine, plus some other minor details (dates, etc..).

1. When I click the ADD button, I would like for it to immediately add the application to a list in the subform. The subform is setup as a continuous form to show all applications. Right now, when I select an application, say Microsoft Office, and click ADD, it initially does nothing. I select a second application, say Adobe Photoshop, and click ADD and it adds Microsoft Office. So it's a step behind. I have the code: me.frmSubLoadset.Requery in my code, but it's delayed. Is there a way to have it populate the field on the subform immediately when clicking ADD?

2. Second, when I click the REMOVE button it should work the same as the ADD button, but just immediately remove the application from the subform...not just from the application field, but that entire record. Here is the code I have so far, but I don't think it's correct. I'm still pretty new at the coding side of Access:

Dim Application as String
Dim db as DAO.Database
Dim rsGroup as DAO.Recordset
Dim rsDel as DAO.Recordset

Application = Me![cboAppList]

Set db = CurrentDb
Set rsGroup = db.OpenRecordset("Select * from [tblSubLoadset] Where LoadsetLinkID =" & Me.LoadsetRecID)

Set rsDel = db.OpenRecordset("Select * from rsGroup Where AppName =" & Application)

rsDel.Delete

Me.frmSubLoadset.Requery



Any help on either of these is GREATLY appreciated.

Thanks much!

Elizabeth :)
 
Oh, I guess it might help to add that for #2, with the code above, when I select an application from the combo box and click REMOVE, I get the following error:

Run-time error '3075':
Syntax error in query expression 'appname = <application name here>'.

Thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top