Adding data to a unbound listbox!

  • Thread starter Niklas Östergren
  • Start date
N

Niklas Östergren

I have two form´s:
1.) <frmCreateEmailMsg>
2.) <frmAddAttachmentsToEmailMsg>

On form No1 (frmCreateEmailMsg) I have a unbound listbox (lstAttachedFiles)
which I want to fill with records selected from a bound listbox
(lstSelectFileName) on form No2 (frmAddAttachmentsToEmailMsg).

The bound control (lstSelectFileName) have following properies:
- RecordSourceType: Table/Query
- RecordSource: SELECT tblDocument ......
- Number of columns: 2
- Bound column: 1

After the user have selected one record from the bound listbox they add it
to the unbound listbox on form No1 with this code:

'============================
If IsLoaded("frmCreateEmailMsg") Then
strSelectedFiles = Me.lstSelectFileName & ";"
Forms!frmCreateEmailMsg.lstAttachedFiles.RowSourceType = "Value List"
Forms!frmCreateEmailMsg.lstAttachedFiles.RowSource =
Forms!frmCreateEmailMsg.lstAttachedFiles.RowSource & strSelectedFiles
End If
'============================

The problem I have is that what´s added to the unbound form is the first
column from the bound form. Which menas that the data added to the unbound
listbox is a primary key.

What I´d like to add is BOTH the primary key (column 1) AND Document path
which is shown in column 2 of the bound control.

I just don´t know how to do this!

TIA!
// Niklas
 
N

Niklas Östergren

I have another problem with this as well. I think it has to do with this
code which goes in a cmd´s Click_Event (cmdOK):

'=========================
If IsLoaded("frmCreateEmailMsg") Then
strSelectedFiles = Me.lstSelectFileName & ";"
Forms!frmCreateEmailMsg.lstAttachedFiles.RowSourceType = "Value List"
Forms!frmCreateEmailMsg.lstAttachedFiles.RowSource =
Forms!frmCreateEmailMsg.lstAttachedFiles.RowSource & strSelectedFiles
End If

'===========================================

It adds the value to the unbound listbox. But not untill I have clicked
twice on the cmd. Or to be more correct. I can´t SEE the added data in the
unbound listbox until I have clicked twice. And I have to click twice for
every data I have to copy to the unbound listbox.

Any idéa?

TIA!
// Niklas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top