解决Access女士连续表格吗? [英] Work around Ms Access continuous form?

查看:92
本文介绍了解决Access女士连续表格吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

我想以以下形式完成两件事

In the following form i want to accomplish two things


  • 如果选中发布复选框,即当发布= true时,查询应仅针对当前记录并减去客户表中带有余额的金额字段。

  • When Post check box is ticked i.e. when post= true a query should run targeting the current record only and subtracting the amount with balance field in the customer table.

更新客户内部联接[Customer.CUSID = [Loan Payment] .CUSID SET Customer.CUSBalance = [Customer]![CUSBalance]-[Forms]![Loan Payment]![Amount] $ b上的[贷款付款]! $ b WHERE((((Customer.CUSID)= [Forms]![Loan Payment]![CUSID])));

UPDATE Customer INNER JOIN [Loan Payment] ON Customer.CUSID = [Loan Payment].CUSID SET Customer.CUSBalance = [Customer]![CUSBalance]-[Forms]![Loan Payment]![Amount] WHERE (((Customer.CUSID)=[Forms]![Loan Payment]![CUSID]));

例如在LP6上执行查询时就代替了[BALANCE] -20,但BALANCE-110却执行了该查询,

BUT INSTEAD THE WHEN THE QUERY IS EXECUTED FOR EXAMPLE ON LP6 INSTEAD OF [BALANCE]-20 IT DOES BALANCE-110 i.e. THE QUERY IS RUNNING ON ALL FIELDS


  • 查询已运行且发布已更改为true后,当前记录的发布复选框应被禁用,以便查询可能不会运行两次或多次

我发现有条件格式不能应用于文本框

AND I FOUND THAT CONDITIONAL FORMATTING CANNOT BE APPLIED TO TEXT BOXES

要求


  1. 我想知道我是否可以实现自己想要的目标以及如何?

  2. 对我当前想要达到的目标的任何解决方法或替代解决方案。


推荐答案

首先,我使用了错误的SQL。

Firstly, I was using the wrong SQL.

UPDATE Customer SET Customer.CUSBalance = [Customer]![CUSBalance]-[Forms]![Loan Payment]![Amount]
WHERE (((Customer.CUSID)=[Forms]![Loan Payment]![CUSID]));

第二,我发现条件格式无法应用于复选框,因此我不得不找到一种解决方法,我找到了三个。

Secondly I found that conditional formatting can not be applied to check boxes so I had to find a workaround and I found three.

解决1

我锁定了 Post 复选框,并引入了一个按钮,如果 Post = false 将运行查询并使 Post = True

I locked the Post check box and introduced a button which if Post = false would run the query and make Post = True

我的表格现在

代码我在发布按钮上使用了[单击过程]

The Code I used on the post button [on click procedure]

Private Sub Command19_Click()

If Me.Post = False Then
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "updateCustomerLoan"
    DoCmd.SetWarnings True
    Me.Post = True
    MsgBox ("Record has been Posted")
ElseIf Me.Post = True Then
    MsgBox ("Record has already been posted")
End If

End Sub

解决2

我在 post_update()在这里我写了两个查询,一个做查询(更新),一个撤消查询(更新)

I applied the following code on post_update() where I wrote two queries one do query (update) and one undo query (update)

Private Sub Post_AfterUpdate()
    If Me.Post = True Then
        DoCmd.SetWarnings False
        DoCmd.OpenQuery "payLoanONpost"
        DoCmd.SetWarnings True
        MsgBox ("The record has been posted")
    ElseIf Me.Post = False Then
        DoCmd.SetWarnings False
        DoCmd.OpenQuery "unpayLoanONunpost"
        DoCmd.SetWarnings True
        MsgBox ("Record has been unposted")
    End If
End Sub

解决3个问题(到目前为止是最好的,并且可以完成我最初打算做的事情

这里我只使用了一次更新查询

Here I only used one update query

Private Sub Post_AfterUpdate()
    If Me.Post = True Then
        DoCmd.SetWarnings False
        DoCmd.OpenQuery "payLoanONpost"
        DoCmd.SetWarnings True
        MsgBox ("The record has been posted")
    ElseIf Me.Post = False Then
        MsgBox ("The record cannot unposted")
        Me.Post = True
    End If
End Sub

这篇关于解决Access女士连续表格吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆