Hello All!
I am trying to write VBA for a form using a SQL statement and need help, lots of help! what I would like to do is match values on a form (1 text box and 2 combo boxes)
with another table that match ID's
I would like to then populate an unbound List Box on the form with these values
excluding any values that are 0 (Zero)
something like this below ..
(I don't know how to word this I do apologize; I don't know if i should "if then else" or CASE or even how to format it for Access VBA. Not even sure where to insert WHERE. not sure about the "" and the & etc. etc. just need some simple examples please, Hope this does not cause some programmers to do a facepalm!)
I am trying to write VBA for a form using a SQL statement and need help, lots of help! what I would like to do is match values on a form (1 text box and 2 combo boxes)
with another table that match ID's
I would like to then populate an unbound List Box on the form with these values
excluding any values that are 0 (Zero)
something like this below ..
(I don't know how to word this I do apologize; I don't know if i should "if then else" or CASE or even how to format it for Access VBA. Not even sure where to insert WHERE. not sure about the "" and the & etc. etc. just need some simple examples please, Hope this does not cause some programmers to do a facepalm!)
Code:
dim mySQL as string
mySQL = "SELECT * FROM tblPEOPLE Where tblPEOPLEID = [txtPERSONID]
IF
[PERSONID] = ZERO THEN
Ignore, if its anything but zero add to mySQL to display in List Box
If its not [Forms]![frmMAIN].[cboPerson] = mySQL
IF
[PERSONID2] = is ZERO THEN
mySQL = [Forms]![frmMAIN].[cboPerson2]
IF
[PERSONID3] = is ZERO THEN
mySQL = [Forms]![frmMAIN].[cboPerson2]
EndIf
Me.listMAIN.RowSource = mySQL
Me.listMAIN.Requery
End Sub