我有一个基于参数化查询的报告,需要非常具体的变量,因此我构建了一个带有组合框的表单来收集参数。然后我尝试将变量传递给报告,但是,我无法让它工作,虽然报告打开了,但它一直在问我想要传递给它的变量。
单击命令按钮时,参数将从表单中获取,与收集参数和打开报告相关的代码片段如下:
Dim args as String
args = "[Year Ending]=#" & DateSerial(Year(Me.comboYearEnding.Value), Month(Me.comboYearEnding.Value), Day(Me.comboYearEnding.Value)) & "#," & _
" [Budget Round]=" & Me.comboBudgetRound & _
" [Organisational Hierarchy Version]=" & Me.comboOrgHierarchy.Value & _
" [Nominal Hierarchy Version]=" & Me.comboNomHierarchy & _
" [Group ID]=" & Me.comboGroup.Value & _
" [Unit ID]=" & Me.comboUnit.Value & _
" [Department ID]=" & Me.comboDepartment
" DoCmd.OpenReport "rptForecast_4_UoW", View:=acViewPreview, OpenArgs:=args
这将打开报告,并且args字符串具有所有正确的值,但是,在打开时,报告会再次询问每个列出的参数,除非我输入它们,否则报告将打开,如“#Type!”错误,我假设因为基础查询没有参数可以使用。
任何人都可以解释我哪里出错了,并在错误所在的地方说清楚。
非常感谢,
西蒙
答案 0 :(得分:0)
首先,插入private static final long serialVersionUID = -1401667790158007207L;
int playerx = 450;
int playery = 450;
int playerDirection = 0; //north = 0, west = 1, south = 2, east = 3
boolean setBlock;
public platform(){
super("2D game");
JPanel panel = new JPanel();
panel.setBackground(Color.white);
addKeyListener(this);
this.setContentPane(panel);
}
public void paint(Graphics g){
super.paint(g);
Graphics2D g2 = (Graphics2D)g;
Rectangle player = new Rectangle(playerx, playery, 50, 50);
g2.fill(player);
if(setBlock){
if(playerDirection == 0){
g2.fillRect(playerx, playery - 50, 50, 50);
}else if(playerDirection == 1){
g2.fillRect(playerx + 50, playery, 50, 50);
}else if(playerDirection == 2){
g2.fillRect(playerx, playery + 50, 50, 50);
}else if(playerDirection == 3){
g2.fillRect(playerx - 50, playery, 50, 50);
}
setBlock = false;
}
}
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == KeyEvent.VK_UP){
playerDirection = 0;
playery -=50;
repaint();
}
if(e.getKeyCode() == KeyEvent.VK_DOWN){
playerDirection = 2;
playery +=50;
repaint();
}
if(e.getKeyCode() == KeyEvent.VK_RIGHT){
playerDirection = 1;
playerx += 50;
repaint();
}
if(e.getKeyCode() == KeyEvent.VK_LEFT){
playerDirection = 3;
playerx -=50;
repaint();
}
if(e.getKeyCode() == KeyEvent.VK_SPACE){
setBlock = true;
}
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
供您学习。
其次,日期表达式的格式可能不正确,如果Version是一个字符串,它必须用引号括起来,如果你没有点作为小数分隔符,货币就会出错:
Debug.Print args
修改强>
应该是:
Dim args as String
args = "[Year Ending]=#" & Format(Me.comboYearEnding.Value, "yyyy\/mm\/dd") & "#," & _
" [Budget Round]=" & Str(Me.comboBudgetRound) & _
" [Organisational Hierarchy Version]='" & Me.comboOrgHierarchy.Value & "'" & _
" [Nominal Hierarchy Version]=" & Me.comboNomHierarchy & _
" [Group ID]=" & Me.comboGroup.Value & _
" [Unit ID]=" & Me.comboUnit.Value & _
" [Department ID]=" & Me.comboDepartment
" DoCmd.OpenReport "rptForecast_4_UoW", View:=acViewPreview, OpenArgs:=args