{"id":303,"date":"2014-03-26T07:02:08","date_gmt":"2014-03-25T22:02:08","guid":{"rendered":"http:\/\/wp.ultimai.org\/wp\/?p=303"},"modified":"2014-03-26T07:03:42","modified_gmt":"2014-03-25T22:03:42","slug":"access_db_vba","status":"publish","type":"post","link":"http:\/\/wp.ultimai.org\/?p=303","title":{"rendered":"Access DB\u958b\u767a \u307b\u307cVBA"},"content":{"rendered":"<p>1.\u30af\u30a8\u30ea\u3092\u4f7f\u308f\u305a\u306bSQL\u6587\u3067\u5236\u5fa1\u3059\u308b\u65b9\u6cd5<br \/>\n\u3068\u308a\u3042\u3048\u305aDAO\u3092\u4f7f\u3046<br \/>\n\u3053\u3093\u306a\u611f\u3058\u306b\u5ba3\u8a00<\/p>\n<p>    Dim DB As DAO.Database<br \/>\n    Dim RS As DAO.Recordset<br \/>\n    Dim MQ As QueryDef<br \/>\n  Set DB = CurrentDb<\/p>\n<p>strSQL = strSQL &#038; &#8220;SELECT \u30fb\u30fb\u30fb<br \/>\n\u3068\u308a\u3042\u3048\u305aVB6\u7cfb\u3067\u306f \u7d50\u5408\u4ee3\u5165 .=  += \u3068\u304b\u304c\u4f7f\u3048\u306a\u3044\u306e\u3067\u56de\u308a\u304f\u3069\u304f\u66f8\u304f\u3057\u304b\u306a\u3044\u3002 \u2192 strSQL = strSQL &#038;<\/p>\n<p>\u30af\u30a8\u30ea\u5185\u3067\u306f\u3001ROUND\u304c\u4f7f\u3048\u306a\u3044\u3089\u3057\u3044\u3002\u30d3\u30eb\u30c9\u306e\u4e00\u89a7\u306b\u306f\u51fa\u308b\u306e\u306b\u7d50\u679c\u306f\u5168\u304f\u53cd\u6620\u3057\u306a\u3044\u306e\u3067\u6ce8\u610f!!<br \/>\n\u3057\u304b\u305f\u306a\u304f\u3001INT \u3067\u5bfe\u5fdc\u3002+0.99\u306f\u5c11\u6570\u7b2c2\u3067\u5207\u308a\u4e0a\u3052\u308b\u305f\u3081\u306e\u51e6\u7f6e\u3002<\/p>\n<p>WHERE\u306e()\u304c\u304f\u3069\u3044\u306e\u3067\u524a\u9664\u3057\u305f\u3089\u3001\u6761\u4ef6\u304c\u9069\u7528\u3055\u308c\u306a\u304f\u306a\u3063\u305f\u306e\u3067\u30af\u30a8\u30ea\u3067\u81ea\u52d5\u3067\u4f5c\u6210\u3055\u308c\u305f\u30ab\u30c3\u30b3\u306f\u6d88\u3055\u306a\u3044\u65b9\u304c\u3044\u3044\u3002<\/p>\n<p>\u8a08\u7b97\u5f0f\u304c\u306f\u3044\u3063\u305f\u30ab\u30e9\u30e0\u3067\u6574\u5217\u3084WHERE\u53e5\u3092\u66f8\u304f\u3068\u30d1\u30e9\u30e1\u30fc\u30bf\u30af\u30a8\u30ea\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u3002<br \/>\n\u958b\u304f\u3068\u304d\u306b\u3044\u3061\u3044\u3061\u30d1\u30e9\u30e1\u30fc\u30bf\u304c\u8db3\u308a\u307e\u305b\u3093\u30011\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u300d\u3068\u304b\u805e\u3044\u3066\u304f\u308b\u306e\u3067\u305d\u308c\u3092\u56de\u907f\u3059\u308b\u65b9\u6cd5<\/p>\n<p>2.SQL\u6587\u306e\u5b9f\u884c\u3067\u805e\u3044\u3066\u304f\u308b\u5834\u5408<\/p>\n<p>Set MyQuery = DB.CreateQueryDef(&#8220;&#8221;)  &#8216;\u30af\u30a8\u30ea\u3092\u30bb\u30c3\u30c8<br \/>\nstrSQL = &#8220;PARAMETERS [\u30ab\u30e9\u30e0\u540d] TEXT;&#8221;&#8216;SQL\u6587\u306e\u5148\u982d\u306b\u66f8\u304f<\/p>\n<p>\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3059\u308b \u2192 &#8216;Set RS = DB.OpenRecordset(strSQL) \u3053\u308c\u3067\u306f\u958b\u3051\u306a\u3044\u306e\u3067\u3002<br \/>\n\u4ee3\u308f\u308a\u306b\u3053\u306e\u6587\u3092<br \/>\n        With MyQuery  &#8216;SQL\u6587\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6e21\u3057\u3066\u304b\u3089\u5b9f\u884c<br \/>\n          .SQL = strSQL<br \/>\n          .Parameters(0) = 1    &#8216;0\u306f\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3001\u50241\u3092\u5165\u308c\u308b<br \/>\n          Set RS = .OpenRecordset()  &#8216;\u30af\u30a8\u30ea\u5b9f\u884c<br \/>\n        End With<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u30af\u30a8\u30ea\u3092\u4f7f\u308f\u305a\u306bSQL\u6587\u3067\u5236\u5fa1\u3059\u308b\u65b9\u6cd5 \u3068\u308a\u3042 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,1],"tags":[],"class_list":["post-303","post","type-post","status-publish","format-standard","hentry","category-access","category-php"],"_links":{"self":[{"href":"http:\/\/wp.ultimai.org\/index.php?rest_route=\/wp\/v2\/posts\/303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wp.ultimai.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wp.ultimai.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wp.ultimai.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/wp.ultimai.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=303"}],"version-history":[{"count":0,"href":"http:\/\/wp.ultimai.org\/index.php?rest_route=\/wp\/v2\/posts\/303\/revisions"}],"wp:attachment":[{"href":"http:\/\/wp.ultimai.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wp.ultimai.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=303"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wp.ultimai.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}