无法保存在表中的消息框

时间:2017-03-22 05:36:40

标签: sql visual-foxpro

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")

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

2 个答案:

答案 0 :(得分: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 :(得分:-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