check if combos are equal

maxmangion

AWF VIP
Local time
Today, 05:45
Joined
Feb 26, 2003
Messages
2,805
i have 2 unbound combo boxes in a form. in the first combo box i have the following in the record source:

SELECT tblAlbums.AlbumID, tblAlbums.SongsAmount FROM tblAlbums WHERE tblAlbums.AlbumID=Forms!frmViews!Combo5;

{where combo5 is another combo in the form which displays all available albums}

in the second unbound combo i have this in the control source:

=DCount("Song","qryViewAlbums")

so far this works fine ... example if i have 3 songs from an album of 15 songs, the unbound combos displays 15 and 3

now i want that when both combos are equal i would get a msgbox stating that it is a full album. i was thinking of the following code:

Code:
if cint(Me.AlbumAmount) = cint(Me.SongsAmount) Then
Msgbox "Full Album"
End If

if the above is correct, pls which event shall i put it in ?

Thank you!
 
Being that I don't know exactly how your form is set up I would say to experiment with where to put the code. Wherever it is that you add new songs to fill up the album is where I would put the code, for instance in an After Update of a text box.
 
basically, this form is just a view form and not a form where i add new songs in it! in this form all i have are an unbound combo box which displays all albums i have in the database, then as soon as i select an album from this combo a sub form displays all songs which i have from that album.

Then i have the two unbound combo boxes which i described above, one that displays the total amount of songs which are in that album, and one which counts the number of songs which i have from that album!

actually u have tried the after update and the on change of the combo box which lists the albums, but nothing happened when the amounts are equal (which means that album is complete).
 
I would try doing a step debug on your code so you can find out the actual values of the two controls your are comparing.

Or, another way to do it is to put a MsgBox in one of the events of one of your combo boxes:

MsgBox Me.AlbumAmount & "-" & Me.SongsAmount

This will show you the values of the 2 controls when the event fires to help you track down why the code is not working.
 
thank you very much, your idea of using the msgbox, to see what where the outputs ... it helped me track down my problem.

the problem was that one of the unbound combo box had select albumid, songsamount ... therefore i had to use column(1), because i was getting the value of albumid rather than that of songsamount from that combo ... that's why nothing was happening !
 

Users who are viewing this thread

Back
Top Bottom