wiklendt
i recommend chocolate
- Local time
- Today, 11:58
- Joined
- Mar 10, 2008
- Messages
- 1,746
hi,
using access 2007 on a vista home premium machine. i have two listboxes, one for 'available' word definitions, another for 'selected' word defintions. things work fine (-ish; i've had to debug a lot from a sample db i downloaded of uhmm.... somewhere? Utter Access i think).
except now i need to have the code transfer three fields from the available list to the selected list. here is the code i am workign with:
my issue is highlighted where i have red text. on triggering the event (attempting to transfer from available listbox to selected listbox), the code chokes at this step (in red above, or highlighted in debug in attached image).
it is the "definition" in particular it is struggling with. when i subsitute 'definition' for a second instance of 'selection', the values are copied fine into the M-M table. however, when i put in "definiton" it causes and error (see attached images).
i have tried dim-ing the definition as string, variant and not defnining it at all (leaving access to use the default), nothing there helps.
i've checked the two fields (from and to) are the same data type and same size (text, 255 char) and they're in the same order in each query that the listboxes are sourced from.
when i hover over the "definition" it returns the string correctly, but for some reason does not want to insert the value into the field.
i'm not sure where to progress from here, i've been trying to fiddle with this for days as well as bringing up LOTS of threads about listboxes (which ahve been extremely helpful for other bits of my database! LOL) but none seem to specifically identify this problem...
any help i'd be greatful. cheers,
using access 2007 on a vista home premium machine. i have two listboxes, one for 'available' word definitions, another for 'selected' word defintions. things work fine (-ish; i've had to debug a lot from a sample db i downloaded of uhmm.... somewhere? Utter Access i think).
except now i need to have the code transfer three fields from the available list to the selected list. here is the code i am workign with:
Code:
Private Sub cmdGlossaryAdd_Click()
'On Error GoTo Err_cmdGlossaryAdd_Click
'adds glossary items to the 'selected' listbox
Dim selection
Dim Definition As Variant
Dim intPosGlossary As Integer
'Grab current selection value, if any
selection = Me.lstGlossaryAvailable
Definition = Me.lstGlossaryAvailable.Column(2)
'Grab the selection position
intPosGlossary = Me.lstGlossaryAvailable.ItemsSelected(0)
'Leave if there is no current selection
If IsNull(selection) Then Exit Sub
If IsNull(intPosGlossary) Then Exit Sub
'Append the selected entry to the associated table
[red]CurrentDb.Execute "INSERT INTO tblMassageAssignedGlossary (MassageID, TechniqueID, TechniqueDefinition) " & _
"VALUES (" & Me.txtMassageID & ", " & selection & ", " & Definition & ")"[/red]
'Update the list controls
Me.lstGlossarySelected.Requery
Me.lstGlossaryAvailable.Requery
'Set the similar position as selected in the list
If Me.lstGlossaryAvailable.ListCount > 0 Then
Me.lstGlossaryAvailable = Me.lstGlossaryAvailable.ItemData(intPosGlossary)
End If
Exit_cmdGlossaryAdd_Click:
Exit Sub
Err_cmdGlossaryAdd_Click:
Select Case Err.Number
Case 2480
'ignore, not an Error, just no selection made.
Case 2447
'ignore, though never gave this error before!
Case 94
'ignore, but no idea what invalid use of null in this instance is supposed to mean.
Case Else
Msg = "Error # " & Str(Err.Number) & Chr(13) & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
End Select
Resume Exit_cmdGlossaryAdd_Click
End Sub
my issue is highlighted where i have red text. on triggering the event (attempting to transfer from available listbox to selected listbox), the code chokes at this step (in red above, or highlighted in debug in attached image).
it is the "definition" in particular it is struggling with. when i subsitute 'definition' for a second instance of 'selection', the values are copied fine into the M-M table. however, when i put in "definiton" it causes and error (see attached images).
i have tried dim-ing the definition as string, variant and not defnining it at all (leaving access to use the default), nothing there helps.
i've checked the two fields (from and to) are the same data type and same size (text, 255 char) and they're in the same order in each query that the listboxes are sourced from.
when i hover over the "definition" it returns the string correctly, but for some reason does not want to insert the value into the field.
i'm not sure where to progress from here, i've been trying to fiddle with this for days as well as bringing up LOTS of threads about listboxes (which ahve been extremely helpful for other bits of my database! LOL) but none seem to specifically identify this problem...
any help i'd be greatful. cheers,