访问多值字段的插入查询 [英] Access Insert query for Multi-value Field

查看:69
本文介绍了访问多值字段的插入查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Access(2007)表格"ABC" 这是一个与共享点列表"ABC"相关联的表格。在该表中,我有一个字段"Int Banks"。这是一个有5个选择的多值选择字段。因为它是多字段值,用户可以在此字段中插入任​​何一个或组合
的值。


  1. AA
  2. BB
  3. CC
  4. DD
  5. 待定

我需要写一个更新或插入声明如果字段"Int Bank"下没有值比它应该是"5-TBD"


我试过跟随插入查询但没有成功


INSERT INTO [ABC]([Int Banks] ]。[价值])

价值(5-TBD)

WHERE((([ABC]。[Int Banks] .Value)<>" 1 -AA" And([ABC]。[Int Banks] .Value)<>"" 2-BB" And([ABC]。[Int Banks] .Value)<>"" 3-CC" ([ABC]。[Int Banks] .Value)<>" 4-DD"));

解决方案


您没有提到您需要此更新的上下文。



 



您是否尝试更新整个数据库?或者这是在编辑时以某种形式出现的?



 



对于整个数据库,您可以像这样编写一个udpate:


 



< p style ="margin:0in 0in 0pt"> Sub myupdate()



 



   
Dim rst          ; 
作为DAO.Recordset



   
Dim rstChild      作为DAO。记录集



   



   
设置rst = CurrentDb.OpenRecordset(" select id,[Int Banks] from ABC& _& / span>


&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;  " where
[Int Banks] .Value为null")



   
执行rst.EOF = False


< span style ="font-family:Times New Roman; font-size:small">

      
rst.Edit



        
设置rstChild = rst![Int Banks] .value



        
rstChild.AddNew



        
rstChild(0)=" 5-TBD"



        
rstChild.Update



        
rstChild.Close



     
rst.Update


< span style ="font-family:Times New Roman; font-size:small">

     
rst.MoveNext


< span style ="font-family:Times New Roman; font-size:small">

     



   
循环



    rst.close


    rstchild.close    



   



 



结束子



 



Albert D. Kallal  
(访问MVP)



加拿大艾伯塔省埃德蒙顿



 



I have Access (2007) table "ABC" which is a linked table to sharepoint list "ABC". In this table i have one field "Int Banks" which is a multi-value choice field having 5 choices. As it is multi-field value user can insert any one or combination of values in this field.

  1. AA
  2. BB
  3. CC
  4. DD
  5. TBD

I need to write an update or insert statement where if there is no value under field "Int Banks" than it should be "5-TBD"

I have tried following insert query but no success

INSERT INTO [ABC] ( [Int Banks].[Value] )
VALUES (5-TBD)
WHERE ((([ABC].[Int Banks].Value)<>"1-AA" And ([ABC].[Int Banks].Value)<>"2-BB" And ([ABC].[Int Banks].Value)<>"3-CC" And ([ABC].[Int Banks].Value)<>"4-DD"));

解决方案

You do not mention what context you need this update.

 

Are you attempting to update the whole database? Or is this to occur in some form at edit time?

 

For the whole database, you can code a udpate like this:

 

Sub myupdate()

 

    Dim rst          As DAO.Recordset

    Dim rstChild     As DAO.Recordset

   

    Set rst = CurrentDb.OpenRecordset("select id,[Int Banks] from ABC " & _

                          "where [Int Banks].Value is null")

    Do While rst.EOF = False

       rst.Edit

         Set rstChild = rst![Int Banks].value

         rstChild.AddNew

         rstChild(0) = "5-TBD"

         rstChild.Update

         rstChild.Close

      rst.Update

      rst.MoveNext

     

    Loop

    rst.close

    rstchild.close   

   

 

End Sub

 

Albert D. Kallal  (Access MVP)

Edmonton, Alberta Canada

 


这篇关于访问多值字段的插入查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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