Link to home
Start Free TrialLog in
Avatar of d10u4v
d10u4vFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Append to a Litbox

Hi,

I have two forms: frmScanTags and frmScanTagPop

frmScanTags has a listbox lbScannedtags.  frmScanTagPop acts like a popup for which is opened above the frmScanTags table and allows the user to enter a tag number in the single field on this form.

What i am trying to do is what ever tag is entered into the frmScanTagPop form is checked to see if it excits in tblAssignedTags and if so is apended to the listbox in the frmScanTags form.

It would be like querying tblAssignedTags with the data which is entered in the popup form and adding the results to the listbox

Hope someone can help me find a way to achieve this.

Anthony
Avatar of Alan Warren
Alan Warren
Flag of Philippines image

Hi Anthony,
it sounds like you are almost there.
If your popup form is correctly adding tags all you need to do is requery the listbox on the form that invoked the popup.

So in your code that invokes the popup, after the openForm command.
    lbScannedtags.requery


hth

Alan



Avatar of d10u4v

ASKER

That's the problem, its not adding tags, that is what i'm trying to achieve. :(
Anthony
Hi Anthony,

Not really sure how your are invoking your popup form (frmScanTagPop)
but I would do it like this:

I would append and Item to listbox --Add tag--
You can do this by modifying the recordsource for the listbox
eg:
SELECT tblAssignedTags.ID, tblAssignedTags.tag FROM tblAssignedTags; Union All Select 0, "--Add tag--"  FROM tblAssignedTags Where ID = 1

Then you can add a AfterUpdate Event procedure to the the listbox, to invoke your popup form (frmScanTagPop)
like so:

With me so far?

Alan


Private Sub lbScannedtags_AfterUpdate()
 If lbScannedtags.Column(0) = 0 Then
   'Open your popup form
   DoCmd.OpenForm "frmScanTagPop", acNormal, , , acFormAdd, acDialog
 End If
 
 lbScannedtags.Requery
 
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Alan Warren
Alan Warren
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial