-
Does anyone know whats wrong with this code: A error is brought back saying "Object Variable or With Block variable not set"
Private Sub lvwJourneys_Click()
TxtJourneyID.Text = Trim(lvwJourneys.SelectedItem.Text)Txtjourneyfrom.Text = Trim(lvwJourneys.SelectedItem.SubItems(1))
Txtjourneyto.Text = Trim(lvwJourneys.SelectedItem.SubItems(2))
Txtstandardmiles.Text = Trim(lvwJourneys.SelectedItem.SubItems(3))
End Sub
-
Code:
Private Sub lvwJourneys_Click()
TxtJourneyID.Text = Trim(lvwJourneys.SelectedItem.Text)
Txtjourneyfrom.Text = Trim(lvwJourneys.SelectedItem.SubItems(1))
Txtjourneyto.Text = Trim(lvwJourneys.SelectedItem.SubItems(2))
Txtstandardmiles.Text = Trim(lvwJourneys.SelectedItem.SubItems(3))
End Sub
...should work... shouldn't it? If you were trying to run the exact code you posted, you had a carriage return in the wrong place.
-
you get that error if you refer to an object reference without an object, so check out which of them isn't refering to anything at make sure either to make a new reference or you shouldn't handle the object at all, by avoiding it with errorhandling