Adding Items...

AuroX7

Registered User.
Local time
Today, 14:36
Joined
Feb 22, 2006
Messages
44
I've made a button on my form which adds a booking ID into the listbox, but it doesn't seem to work. This is my code:

Private Sub Command18_Click()
Dim BoI As String

MsgBox "Booking successfully added!", vbInformation, "Booking"

If Month(Me.Date_1) = 1 Then
ListJ.AddItem Me.BoI
ElseIf Month(Me.Date_1) = 2 Then
ListF.AddItem Me.BoI
End If
End Sub

If someone could tell me the problem, I'd appreciate it. Thank you. :)
 
I've never done an AddItem but you may need to use something like:

me.ListJ.AddItem Me.BoI

???
 
i think you need to declare another variable to save the message's "response"

for example:
Dim msg As String
msg = MsgBox "Booking successfully added!", vbInformation, "Booking"

Not sure if this is the line that caused your problem but correcting it won't harm :)
 
wleong,

I'm not sure why you're suggestion he save a response from the message (?)

And I'm also not sure what you've suggested would work anyway...
 
It highlights 'AddItem' with an error... 'Compile error: Argument not optional'

Private Sub Command18_Click()
Dim BoI As String

MsgBox "Booking successfully added!", vbInformation, "Booking"

If Month(Me.Date_1) = 1 Then
Me.ListJ.AddItem Me.BoI
ElseIf Month(Me.Date_1) = 2 Then
Me.ListF.AddItem Me.BoI
End If
End Sub
___________________________________
BoI is the booking ID and I want it to go into the ListJ or ListF box depending whether the booking ID is Jaunary or February
 
if you type ListJ.
then do you have the additem option in the opened list?

i strangely don't and here is an opportunity to ask wiser people, what could be wrong with my access?

i also can't declare this:
Dim db As Database
 
Last edited:

Users who are viewing this thread

Back
Top Bottom