Friday 15 January 2010

word vba - VBA adding a list empty fields from a userform to a message box -



word vba - VBA adding a list empty fields from a userform to a message box -

i have created userform requires user input several strings or integers. trying message box come if several of mandatory boxes not filled in. want list empty fields skip fields filled in. know how loop if values integers of inputs strings. think dim c control, , know general layout of message box, stumped beyond that. please help don’t have write 6 separate conditional statements 6 separate message boxes!

the 6 form field names are: proposal_name, date_of_submission, cbocontraact_type, contract_neg_name, contract_neg_number, , validity_period

the general layout of message box had in mind follows:

msgbox "you have left next mandatory fields empty:" & vbcrlf & vbcrlf & "proposal_name" & vbnewline & "date_of_submission" & chr(10) & "cbocontraact_type" & chr(10) & "contract_neg_name" & chr(10) & "validity_period"

since concerned 6 fields, not go downwards path of looping through form controls, determining command type, checking missing value, etc.

here onclick command button might work you:

private sub command12_click() dim smissingvalues string smissingvalues = "" if nz(me!proposal_name, "") = "" smissingvalues = smissingvalues + vbcrlf + "proposal_name" if nz(me!date_of_submission, "") = "" smissingvalues = smissingvalues + vbcrlf + "date_of_submission" if nz(me!cbocontraact_type, "") = "" smissingvalues = smissingvalues + vbcrlf + "cbocontraact_type" if nz(me!contract_neg_name, "") = "" smissingvalues = smissingvalues + vbcrlf + "contract_neg_name" if nz(me!contract_neg_number, "") = "" smissingvalues = smissingvalues + vbcrlf + "contract_neg_number" if nz(me!validity_period, "") = "" smissingvalues = smissingvalues + vbcrlf + "validity_period" if smissingvalues <> "" msgbox "you have left next mandatory fields empty:" & vbcrlf & smissingvalues end if end sub

word-vba msgbox

No comments:

Post a Comment