我想用另一个记录集打开VBA记录集。
如果我编写SQL并将其保存到名为new_entry和valid_unit
的查询中,则此方法有效' valid_unit
SELECT *
FROM import_raw_data
WHERE unit_name IN (SELECT unit_name FROM unit);
' new_entry
SELECT *
FROM valid_unit
WHERE id NOT IN (SELECT id FROM serviceman);
WHERE
但是,我想在VBA中独占而不是保存查询。
Sub testing()
valid_unit_sql = _
"SELECT * " _
& "FROM import_raw_data"
& "WHERE unit_name IN (SELECT unit_name FROM unit);
new_entry_sql = _
"SELECT * "
& "FROM ( " & valid_unit_sql & ") " _
& "WHERE id NOT IN (SELECT id FROM serviceman);"
With CurrentDb
Set valid_unit = .OpenRecordset(valid_unit_sql)
' valid_unit works great
Set new_entry = .OpenRecordset(new_entry_sql)
' this doesnt, it errors out
End With
End Sub
我可以知道我该怎么办?我应该保存我的valid_unit查询和FROM valid_unit吗?
答案 0 :(得分:0)
您的引号use DmitryDulepov\Realurl\Cache\UrlCacheEntry;
class RealurlUrlDecoder extends \DmitryDulepov\Realurl\Decoder\UrlDecoder {
/**
* Sets variables after the decoding.
*
* @param UrlCacheEntry $cacheEntry
*/
public function setRequestVariables(UrlCacheEntry $cacheEntry) {
$languageWithoutDomain = array(
3 => '/pt/',
6 => '/us/',
7 => '/fr/',
);
if (in_array(substr($_SERVER['REQUEST_URI'], 0, 4), $languageWithoutDomain)) {
foreach ($languageWithoutDomain as $key => $value) {
if(substr($_SERVER['REQUEST_URI'], 0, 4) == $value){
$requestVariables = $cacheEntry->getRequestVariables();
if(isset($requestVariables['L'])){
$requestVariables['L'] = $key;
$cacheEntry->setRequestVariables($requestVariables);
}
}
}
}
parent::setRequestVariables($cacheEntry);
}
}
和新续行"
有点搞砸了。我不知道这是复制粘贴错误还是你的实际代码(不编译)。
无论如何都试试这个:
& _
输出SQL:
Sub testing()
valid_unit_sql = "SELECT * " & _
"FROM import_raw_data " & _
"WHERE unit_name IN (SELECT unit_name FROM unit)"
new_entry_sql = "SELECT * " & _
"FROM (" & valid_unit_sql & ") AS T " & _
"WHERE T.id NOT IN (SELECT id FROM serviceman);"
Debug.Print new_entry_sql
With CurrentDb
Set valid_unit = .OpenRecordset(valid_unit_sql)
Set new_entry = .OpenRecordset(new_entry_sql)
End With
End Sub