【问题标题】:Message box that cannot save in table无法保存在表格中的消息框
【发布时间】:2017-03-22 05:36:40
【问题描述】:
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")

当我点击我的添加按钮并且没有人在我的文本框中输入时,它会弹出警告消息,但它可以将它保存在我的表格中。你能帮我解决我的代码问题吗,当没有人输入时,它无法保存在我的表格中。谢谢

【问题讨论】:

    标签: sql visual-foxpro


    【解决方案1】:

    您的代码很难阅读且不完整,看起来您的最后一个表达式不正确。可能你的意思是:

    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
    

    【讨论】:

      【解决方案2】:

      看看你最后的IFstatement。当所有字段实际上都有值时,您有 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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-03-19
        • 1970-01-01
        • 1970-01-01
        • 2018-06-24
        • 1970-01-01
        • 1970-01-01
        • 2022-08-09
        • 2021-12-10
        相关资源
        最近更新 更多