2017-03-22 4 views
0
IF EMPTY(thisform.docnum.value)=.T. or EMPTY(thisform.doctype.value)=.T. then 
    MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 
ELSE  
    IF EMPTY(thisform.doctitle.value)=.T. or EMPTY(thisform.docdate.value)=.T. then 
    MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 
ELSE 
    IF EMPTY(thisform.recdate.value)=.T. or EMPTY(thisform.pubdate.value)=.T. then 
    MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 
ELSE 
    IF EMPTY(thisform.sector.value)=.T. or EMPTY(thisform.cluster.value)=.T. then 
    MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 
ELSE 
    IF EMPTY(thisform.region.value)=.T. or EMPTY(thisform.revision.value)=.T. then 
    MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 
ELSE 
    IF EMPTY(thisform.procby.value)=.T. or EMPTY(thisform.revby.value)=.T. then 
    MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 
ELSE 
    IF EMPTY(thisform.encby.value)=.T. then 
ELSE  
    MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 

[追加]ボタンをクリックすると、テキストボックスに何も入力しなくても警告メッセージがポップアップ表示されますが、テーブルに保存できます。私のコードに何が問題になるのか教えてください。誰も入力しなければテーブルに保存できません。ありがとうテーブルに保存できないメッセージボックス

答えて

3

あなたのコードは非常に読みにくく、不完全で、あなたの最後の式が間違っているようです。おそらくあなたは、このことを意味:

If Empty(Thisform.docnum.Value) Or Empty(Thisform.doctype.Value) Or ; 
     Empty(Thisform.doctitle.Value) Or Empty(Thisform.docdate.Value) Or ; 
     Empty(Thisform.recdate.Value) Or Empty(Thisform.pubdate.Value) Or ; 
     Empty(Thisform.sector.Value) Or Empty(Thisform.cluster.Value) Or ; 
     Empty(Thisform.Region.Value) Or Empty(Thisform.revision.Value) Or ; 
     Empty(Thisform.procby.Value) Or Empty(Thisform.revby.Value) Or ; 
     Empty(Thisform.encby.Value) 
    Messagebox("Unabled to save all fields required !",0+64,"Warning") 
Else 
    * Save operation 
Endif 
-1

は、あなたの最終IFの文を見てみましょう。すべてのフィールドに実際に値が設定されている場合、「保存できません」というメッセージがMessageBoxにあります。

多分これにそれを変更してみてください:

IF EMPTY(THISFORM.docnum.VALUE)=.T. OR EMPTY(THISFORM.doctype.VALUE)=.T. then 
    MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 
ELSE 
    IF EMPTY(THISFORM.doctitle.VALUE)=.T. OR EMPTY(THISFORM.docdate.VALUE)=.T. then 
     MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 
    ELSE 
     IF EMPTY(THISFORM.recdate.VALUE)=.T. OR EMPTY(THISFORM.pubdate.VALUE)=.T. then 
      MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 
     ELSE 
      IF EMPTY(THISFORM.sector.VALUE)=.T. OR EMPTY(THISFORM.cluster.VALUE)=.T. then 
       MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 
      ELSE 
       IF EMPTY(THISFORM.REGION.VALUE)=.T. OR EMPTY(THISFORM.revision.VALUE)=.T. then 
        MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 
       ELSE 
        IF EMPTY(THISFORM.procby.VALUE)=.T. OR EMPTY(THISFORM.revby.VALUE)=.T. then 
         MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 
        ELSE 
         IF EMPTY(THISFORM.encby.VALUE)=.T. then 
          MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 
         ELSE 
          **All fields have values here, save to table** 
         ENDIF 
        ENDIF 
       ENDIF 
      ENDIF 
     ENDIF 
    ENDIF 
ENDIF 

あなたはそれがより組織的かつ読みやすくするためだけでなく、このためCASE文を使用して試みることができます。

DO CASE 
    CASE EMPTY(THISFORM.docnum.VALUE) OR EMPTY(THISFORM.doctype.VALUE) 
     MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 

    CASE EMPTY(THISFORM.doctitle.VALUE) OR EMPTY(THISFORM.docdate.VALUE) 
     MESSAGEBOX("Unabled to save all fields required !",0+64,"Warning") 

    OTHERWISE 
     **code to save to table** 
ENDCASE 
関連する問題