Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql Stockcheck以更新库存表_Sql_Ms Access_Vba - Fatal编程技术网

Sql Stockcheck以更新库存表

Sql Stockcheck以更新库存表,sql,ms-access,vba,Sql,Ms Access,Vba,因此,我的项目进展顺利,我创建了一个新表单,供用户在盘点后手动输入库存水平 到目前为止,我的编码如下 Private Sub StockTake_Click() 'Introduce items and variables Dim Carling As Integer Dim Carlsburg As Integer Dim IPA As Integer Dim Strongbow As Integer Dim RevJames As Integer Dim Becks As Integer

因此,我的项目进展顺利,我创建了一个新表单,供用户在盘点后手动输入库存水平

到目前为止,我的编码如下

Private Sub StockTake_Click()

'Introduce items and variables
Dim Carling As Integer
Dim Carlsburg As Integer
Dim IPA As Integer
Dim Strongbow As Integer
Dim RevJames As Integer
Dim Becks As Integer
Dim WKDBlue As Integer
Dim WKDRed As Integer
Dim SmirnoffIce As Integer
Dim KoppaburgPear As Integer
Dim KoppaburgSum As Integer
Dim Bulmers As Integer
Dim Vodka As Integer
Dim Gin As Integer
Dim Sherry As Integer
Dim Sambuca As Integer
Dim Rum As Integer
Dim Port As Integer
Dim Whiskey As Integer
Dim Baileys As Integer
Dim Jagermeister As Integer
Dim Martini As Integer
Dim CokeCan As Integer
Dim Coke As Integer
Dim LemonadeCan As Integer
Dim Lemonade As Integer
Dim Squash As Integer
Dim Tonic As Integer
Dim RedBull As Integer
Dim Nuts As Integer
Dim Crisps As Integer
Dim SQLError As String
Dim SQLDelete As String
Dim SQLUpdate As String
Dim SQLBackup As String
Dim PubStock As Integer

'define items. these "Txtname" are text boxes on the form that the user can enter the values into... already this seems like a massive 'code.
Carling = txtCarling
Carlsburg = txtCarlsburg
IPA = txtIPA
Strongbow = txtStrongbow
RevJames = txtRevJames
Becks = txtBecks
WKDBlue = txtWKDBlue
WKDRed = txtWKDRed
SmirnoffIce = txtSmirnoffIce
KoppaburgPear = txtKopPear
KoppaburgSum = txtKopSum
Bulmers = txtBulmers
Vodka = txtVodka
Gin = txtGin
Sherry = txtSherry
Sambuca = txtSambuca
Rum = txtRum
Port = txtPort
Whiskey = txtWhiskey
Baileys = txtBaileys
Jagermeister = txtJagermeister
Martini = txtMartini
CokeCan = txtCokeCan
Coke = txtCokeDra
LemonadeCan = txtLemonadeCan
Lemonade = txtLemonadeDra
Squash = txtSquash
Tonic = txtTonic
RedBull = txtRedBull
Nuts = txtNuts
Crisps = txtCrisps

'introduce SQL coding
SQLDelete = "DELETE * FROM TblStock"

SQLUpdate = "update the tblstock with the values from the form based on the name of the product. tblStock contains StockID*, ProductID and stockLevel which is just the added stock values, not the on hand stock. thus the new value inputed on the form should replace all current values in the table. "

SQLBackup = "export all data in tblStock to update values in an excel table, ie, add to the data allready there, not replace it."

'Start actual coding
If Carling = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Carlsburg = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If IPA = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Strongbow = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If RevJames = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Becks = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If WKDBlue = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If WKDRed = Null Then MsgBox "Plese Fill in all areas of the form to complete the  Stock Take and try again" Else
If SmirnoffIce = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If KoppaburgPear = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If KoppaburgSum = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Bulmers = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Vodka = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Gin = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Sherry = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Sambuca = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Rum = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Port = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Whiskey = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Baileys = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Jagermeister = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Martini = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If CokeCan = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If Coke = Null Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again" Else
If LemonadeCan = Null Then MsgBox "Please Fill in all areas of the form to complete the Stock Take and try again" Else
If Lemonade = Null Then MsgBox "Please Fill in all areas of the form to complete the Stock Take and try again" Else
If Squash = Null Then MsgBox "Please Fill in all areas of the form to complete the Stock Take and try again" Else
If Tonic = Null Then MsgBox "Please Fill in all areas of the form to complete the Stock Take and try again" Else
If RedBull = Null Then MsgBox "Please Fill in all areas of the form to complete the Stock Take and try again" Else
If Nuts = Null Then MsgBox "Please Fill in all areas of the form to complete the Stock Take and try again" Else
If Crisps = Null Then MsgBox "Please Fill in all areas of the form to complete the Stock Take and try again" Else PubStock = 1


If PubStock = 1 Then DoCmd.RunSQL SQLBackup
DoCmd.SetWarnings False
DoCmd.RunSQL SQLDelete
DoCmd.SetWarnings True
DoCmd.RunSQL SQLUpdate

If PubStock <> 1 Then MsgBox "Plese Fill in all areas of the form to complete the Stock Take and try again"

End Sub
Private Sub-StockTake\u Click()
'引入项目和变量
作为整数的Dim-Carling
Dim Carlsburg作为整数
将IPA设置为整数
Dim Strongbow作为整数
作为整数的数字
Dim Beck作为整数
将WKDBlue设置为整数
将WKDRed设置为整数
Dim SmirnoffIce作为整数
Dim Koppa作为整数
Dim KoppaburgSum作为整数
作为整数的Dim Bulmers
调暗伏特加为整数
作为整数的Dim-Gin
暗淡雪利酒
Dim Sambuca作为整数
将Rum设置为整数
将端口设置为整数
暗淡的威士忌
Dim Baileys作为整数
Dim Jagermeister作为整数
Dim Martini作为整数
Dim CokeCan作为整数
淡色焦炭为整数
Dim LemonadeCan作为整数
调淡柠檬水为整数
Dim Squash作为整数
整数
Dim RedBull作为整数
将螺母调整为整数
整片薯片
将SQLError设置为字符串
Dim SQLDelete作为字符串
Dim SQLUpdate作为字符串
将SQLBackup设置为字符串
将PubStock设置为整数
'定义项目。这些“Txtname”是表单上的文本框,用户可以在其中输入值。。。这似乎已经是一个庞大的“代码”。
纵梁=TXT纵梁
卡尔斯堡=特克斯卡尔斯堡
IPA=txtIPA
Strongbow=TXSTRONGBOW
RevJames=txtRevJames
贝克=txtBecks
WKDBlue=txtWKDBlue
WKDRed=txtWKDRed
SmirnoffIce=txtmirnoffice
KoppaburgPear=txtKopPear
KoppaburgSum=txtKopSum
Bulmers=txtBulmers
伏特加
Gin=txtGin
雪莉酒
Sambuca=txtssambuca
Rum=txtRum
端口=txtPort
威士忌
贝利=TXT贝利
Jagermeister=txtJagermeister
马提尼
可乐罐=txtCokeCan
焦炭=txtCokeDra
柠檬汽水
柠檬水
挤压
主音
红牛
螺母=TXT螺母
薯片=txtCrisps
'介绍SQL编码
SQLDelete=“从TblStock删除*
SQLUpdate=“根据产品名称使用表单中的值更新tblstock。tblstock包含StockID*、ProductID和stockLevel,它们只是添加的库存值,而不是现有库存。因此,表单上输入的新值应替换表中的所有当前值。”
SQLBackup=“导出tblStock中的所有数据以更新excel表中的值,即,将数据添加到allready,而不是替换它。”
'开始实际编码
如果Carling=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Carlsburg=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果IPA=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Strongbow=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果RevJames=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Becks=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果WKDBlue=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”,否则
如果WKDRed=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”,否则
如果SmirnoffIce=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果KoppaburgPear=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果KoppaburgSum=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Bulmers=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Vodka=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Gin=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Sherry=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Sambuca=Null,则MsgBox“请填写表单的所有区域以完成盘点并重试”否则
如果Rum=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Port=Null,则MsgBox“请填写表单的所有区域以完成盘点并重试”否则
如果威士忌=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Baileys=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Jagermeister=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Martini=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果CokeCan=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Coke=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果LemonadeCan=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Lemonade=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Squash=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Tonic=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”,否则
如果RedBull=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”否则
如果Nuts=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”,否则
如果Crisps=Null,则MsgBox“请填写表格的所有区域以完成盘点并重试”,否则PubStock=1
如果PubStock=1,则DoCmd.RunSQL
item_id item_name
      1 Baileys
      2 Becks
      3 Bulmers
SELECT
    inv.item_id,
    items.item_name,
    inv.quantity
FROM
    tblScratchInventory AS inv
    INNER JOIN tblStockItems AS items
    ON inv.item_id = items.item_id
ORDER BY items.item_name;
Private Sub Form_Open(Cancel As Integer)
    Dim db As DAO.Database
    Dim strSql As String
    Set db = CurrentDb
    strSql = "DELETE FROM tblScratchInventory;"
    db.Execute strSql, dbFailOnError
    strSql = "INSERT INTO tblScratchInventory ( item_id )" & vbCrLf & _
        "SELECT tblStockItems.item_id" & vbCrLf & _
        "FROM tblStockItems;"
    db.Execute strSql, dbFailOnError
    Set db = Nothing
    Me.Requery
End Sub
Private Sub cmdDone_Click()
    Dim lngNumNulls As Long
    Dim strNullItems As String
    Dim strMsg As String

    If Me.Dirty Then Me.Dirty = False
    lngNumNulls = DCount("*", "tblScratchInventory", "quantity Is Null")
    Select Case lngNumNulls
    Case 0
        ' do what you need here '
        ' then close the form: '
        DoCmd.Close acForm, Me.name
    Case Is <= 6 ' list individual items if not too many of them '
        Dim rs As DAO.Recordset
        Dim db As DAO.Database
        Dim strSql As String
        strSql = "SELECT item_name" & vbCrLf & _
            "FROM qryScratchInventory" & vbCrLf & _
            "WHERE quantity Is Null" & vbCrLf & _
            "ORDER BY item_name;"
        Set db = CurrentDb
        Set rs = db.OpenRecordset(strSql)
        With rs
            Do While Not .EOF
                strNullItems = strNullItems & vbCrLf & !item_name
                .MoveNext
            Loop
            .Close
        End With
        Set rs = Nothing
        Set db = Nothing
        strMsg = "Please input quantities for these items: " & strNullItems
    Case Else
        strMsg = "Please input quantities for all items."
    End Select
    If Len(strMsg) > 0 Then
        MsgBox strMsg
    End If
End Sub