{"id":6056,"date":"2017-08-30T09:41:01","date_gmt":"2017-08-30T00:41:01","guid":{"rendered":"http:\/\/excelwork.info\/excel\/?p=6056"},"modified":"2017-09-01T09:40:33","modified_gmt":"2017-09-01T00:40:33","slug":"adomove","status":"publish","type":"post","link":"https:\/\/excelwork.info\/excel\/adomove\/","title":{"rendered":"\u30ab\u30ec\u30f3\u30c8\u30ec\u30b3\u30fc\u30c9\u306e\u79fb\u52d5\uff08ADO\uff09MoveFirst\u3001MoveLast\u3001MoveNext\u3001MovePrevious\u3001Move"},"content":{"rendered":"<h2>MoveFirst \u30e1\u30bd\u30c3\u30c9\u3001MoveLast \u30e1\u30bd\u30c3\u30c9\u3001MoveNext \u30e1\u30bd\u30c3\u30c9\u3001MovePrevious \u30e1\u30bd\u30c3\u30c9<\/h2>\n<div class=\"m30-l\">\n<p>Recordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5185\u306e\u30ab\u30fc\u30bd\u30eb\u3092\u79fb\u52d5\u3059\u308b\u306b\u306f\u3001MoveFirst \u30e1\u30bd\u30c3\u30c9\uff08\u5148\u982d\u306e\u30ec\u30b3\u30fc\u30c9\uff09\u3001MoveLast \u30e1\u30bd\u30c3\u30c9\uff08\u6700\u5f8c\u306e\u30ec\u30b3\u30fc\u30c9\uff09\u3001MoveNext \u30e1\u30bd\u30c3\u30c9\uff08\u6b21\u306e\u30ec\u30b3\u30fc\u30c9\uff09\u3001MovePrevious \u30e1\u30bd\u30c3\u30c9\uff08\u524d\u306e\u30ec\u30b3\u30fc\u30c9\uff09\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u672b\u5c3e\u3084\u5148\u982d\u306e\u4f4d\u7f6e\u3092\u8d85\u3048\u305f\u30ab\u30fc\u30bd\u30eb\u3092\u79fb\u52d5\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <em>object<\/em>.<strong>MoveFirst<\/strong><br \/>\n    <em>object<\/em>.<strong>MoveLast<\/strong><br \/>\n    <em>object<\/em>.<strong>MoveNext<\/strong><br \/>\n    <em>object<\/em>.<strong>MovePrevious<\/strong><\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>Recordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<br \/>\n<p class=\"caution4\">MoveFirst \u2026 \u30ab\u30fc\u30bd\u30eb\u3092 Recordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5185\u306e\u5148\u982d\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p class=\"caution4\">MoveLast \u2026 \u30ab\u30fc\u30bd\u30eb\u3092 Recordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5185\u306e\u6700\u5f8c\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p class=\"caution4\">MoveNext \u2026 \u30ab\u30fc\u30bd\u30eb\u3092 \u6b21\u306e\u30ec\u30b3\u30fc\u30c9\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002\u30ab\u30fc\u30bd\u30eb\u4f4d\u7f6e\u304c\u672b\u5c3e\u3092\u8d8a\u3048\u308b\u3068\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u3053\u306e\u6642\u3001<strong>EOF \u30d7\u30ed\u30d1\u30c6\u30a3<\/strong> \u304c <strong>True<\/strong> \u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p class=\"caution4\">MovePrevious \u2026 \u30ab\u30fc\u30bd\u30eb\u3092 \u524d\u306e\u30ec\u30b3\u30fc\u30c9\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002\u30ab\u30fc\u30bd\u30eb\u4f4d\u7f6e\u304c\u5148\u982d\u3092\u8d8a\u3048\u308b\u3068\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u3053\u306e\u6642\u3001<strong>BOF \u30d7\u30ed\u30d1\u30c6\u30a3<\/strong>\u304c <strong>True<\/strong> \u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p class=\"caution4\"><strong>EOF \u30d7\u30ed\u30d1\u30c6\u30a3<\/strong>\u3001<strong>BOF \u30d7\u30ed\u30d1\u30c6\u30a3<\/strong> \u306b\u95a2\u3057\u3066\u306f\u3001<a href=\"https:\/\/excelwork.info\/excel\/adobofeof\/\">BOF \u30d7\u30ed\u30d1\u30c6\u30a3\u30fbEOF \u30d7\u30ed\u30d1\u30c6\u30a3<\/a> \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<\/p><\/div>\n<\/div>\n<br \/>\n<h2>Move \u30e1\u30bd\u30c3\u30c9<\/h2>\n<div class=\"m30-l\">\n<p>Recordset \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5185\u306e\u30ab\u30fc\u30bd\u30eb\u3092\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <em>object<\/em>.<strong>Move<\/strong>( <em>NumRecords<\/em>[, <em>Start<\/em>] )<\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>NumRecords&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u30ab\u30ec\u30f3\u30c8\u30ec\u30b3\u30fc\u30c9\u306e\u4f4d\u7f6e\u3092\u79fb\u52d5\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u6570\uff08\u7b26\u53f7\u4ed8\u304d\u9577\u6574\u6570\u578b\uff08Long\uff09\u306e\u5f0f\u3092\u6307\u5b9a\u3057\u307e\u3059\u30020 \u3088\u308a\u3082\u5927\u304d\u3044\u5024\u3092\u6307\u5b9a\u3057\u305f\u5834\u5408\u3001\u30ab\u30ec\u30f3\u30c8\u30ec\u30b3\u30fc\u30c9\u306e\u4f4d\u7f6e\u306f\u524d\u65b9\u3001\u3064\u307e\u308a\u3001<strong>Recordset<\/strong> \u306e\u7d42\u7aef\u65b9\u5411\u306b\u79fb\u52d5\u3057\u307e\u3059\u30020 \u3088\u308a\u3082\u5c0f\u3055\u3044\u5024\u3092\u6307\u5b9a\u3057\u305f\u5834\u5408\u3001\u30ab\u30ec\u30f3\u30c8\u30ec\u30b3\u30fc\u30c9\u306e\u4f4d\u7f6e\u306f\u5f8c\u65b9\u3001\u3064\u307e\u308a\u3001<strong>Recordset<\/strong> \u306e\u59cb\u7aef\u65b9\u5411\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<\/li>\n<li>Start&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u30d6\u30c3\u30af\u30de\u30fc\u30af\u3068\u3057\u3066\u8a55\u4fa1\u3055\u308c\u308b\u6587\u5b57\u5217\u578b (String) \u307e\u305f\u306f\u30d0\u30ea\u30a2\u30f3\u30c8\u578b (Variant) \u306e\u5024\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<strong>BookmarkEnum \u5024<\/strong>\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\uff08\u7701\u7565\u53ef\uff09\u3002<br \/>\n<table>\n<tr>\n<td align = \"center\" width=\"200\" bgcolor=\"#ffffccc\"><strong>\u5b9a\u6570<\/strong><\/td>\n<td align = \"center\" width=\"50\" bgcolor=\"#ffffccc\"><strong>\u5024<\/strong><\/td>\n<td align = \"center\" width=\"400\" bgcolor=\"#ffffccc\"><strong>\u5185\u5bb9<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adBookmarkCurrent<\/td>\n<td width=\"50\" align = \"center\">0<\/td>\n<td width=\"400\">\u73fe\u5728\u306e\u30ec\u30b3\u30fc\u30c9\u304b\u3089\u958b\u59cb\u3057\u307e\u3059<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adBookmarkFirst<\/td>\n<td width=\"50\" align = \"center\">1<\/td>\n<td width=\"400\">\u6700\u521d\u306e\u30ec\u30b3\u30fc\u30c9\u304b\u3089\u958b\u59cb\u3057\u307e\u3059<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">adBookmarkLast<\/td>\n<td width=\"50\" align = \"center\">2<\/td>\n<td width=\"400\">\u6700\u5f8c\u306e\u30ec\u30b3\u30fc\u30c9\u304b\u3089\u958b\u59cb\u3057\u307e\u3059<\/td>\n<\/tr>\n<\/table>\n<p>\n      <\/li>\n<\/ul>\n<br \/><\/div>\n<\/div>\n<br \/><br \/>\n<h2>MoveFirst\u3001MoveLast\u3001MoveNext\u3001MovePrevious \u4f7f\u7528\u4f8b<\/h2>\n<div class=\"m30-l\">\n<h3 id=\"vba_sample\">\u30b5\u30f3\u30d7\u30ebVBA\u30bd\u30fc\u30b9<\/h3>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"MoveFirst\u3001MoveLast\u3001MoveNext\u3001MovePrevious\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nSub Sample_ADO_Move()\r\n    \r\n    '\u53c2\u7167\u8a2d\u5b9a:Microsoft ActiveX Data Objects 6.1 Library\r\n    \r\n    Dim cn As ADODB.Connection\r\n    Dim Rs As ADODB.Recordset\r\n    Dim constr As String\r\n    Dim DBFile As String\r\n    Dim strSQL As String\r\n    Dim i As Long\r\n    Dim j As Long\r\n    \r\n    DBFile = ActiveWorkbook.Path & \"\\mydb1.accdb\"\r\n    constr = \"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\" & DBFile\r\n    \r\n    Set cn = New ADODB.Connection\r\n    cn.ConnectionString = constr\r\n    cn.Open\r\n    \r\n    strSQL = \"Select * from \u793e\u54e1\u540d\u7c3f where ID < 10 order by ID;\"\r\n    \r\n    Set Rs = New ADODB.Recordset\r\n    Rs.Source = strSQL\r\n    Rs.ActiveConnection = cn\r\n    Rs.Open\r\n    \r\n    With Worksheets(\"Sheet1\")\r\n    \r\n        Rs.MoveFirst\r\n        i = 1\r\n        .Cells.Clear\r\n        Do Until Rs.EOF\r\n            For j = 0 To Rs.Fields.Count - 1\r\n                .Cells(i, j + 1) = Rs(j).Value\r\n            Next j\r\n            Rs.MoveNext\r\n            i = i + 1\r\n        Loop\r\n    \r\n    End With\r\n    \r\n    Rs.Close\r\n    Set Rs = Nothing\r\n    \r\n    cn.Close\r\n    Set cn = Nothing\r\n    \r\nEnd Sub\r\n\u3000\r\n  <\/pre>\n<br \/>\n<h3>\u5b9f\u884c\u7d50\u679c<\/h3>\n<p><a href=\"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/07\/adomove_01.jpg?ssl=1\" rel=\"lightbox[6056]\"><img loading=\"lazy\" src=\"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/07\/adomove_01.jpg?resize=553%2C335&#038;ssl=1\" alt=\"Recordset\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5185\u306e\u30ab\u30fc\u30bd\u30eb\u79fb\u52d5\" width=\"553\" height=\"335\" class=\"alignnone size-full wp-image-6058\" srcset=\"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/07\/adomove_01.jpg?w=553&amp;ssl=1 553w, https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/07\/adomove_01.jpg?resize=400%2C242&amp;ssl=1 400w\" sizes=\"(max-width: 553px) 100vw, 553px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<\/div>\n<br \/><br \/>\n","protected":false},"excerpt":{"rendered":"<p>MoveFirst \u30e1\u30bd\u30c3\u30c9\u3001MoveLast \u30e1\u30bd\u30c3\u30c9\u3001MoveNext \u30e1\u30bd &#8230; <\/p>\n","protected":false},"author":1,"featured_media":6058,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"amp_status":"","spay_email":"","jetpack_publicize_message":""},"categories":[948],"tags":[953,950,721,968,560,969,970,952,951,814,955,949,835],"jetpack_featured_media_url":"https:\/\/i1.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/07\/adomove_01.jpg?fit=553%2C335&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/s4Ye9i-adomove","_links":{"self":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/6056"}],"collection":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/comments?post=6056"}],"version-history":[{"count":10,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/6056\/revisions"}],"predecessor-version":[{"id":6219,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/6056\/revisions\/6219"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media\/6058"}],"wp:attachment":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media?parent=6056"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/categories?post=6056"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/tags?post=6056"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}