English 中文(简体)
VB 用于在2010年MS Access中制作提问表的 VB xript
原标题:VB sxript to make a questionaire form in MS Access 2010

我只想知道如何制作一个连续不断的问卷表格,一旦所有问题都填好后,将更新所有表格。 但是,在它到达网页末尾之前,用户将能够从表格到表格进行前后编辑。

将是这样的:

  1. Total 30 forms
  2. One form only update 1-3 fields in the table
  3. Once the user finished with one form, the form will close and open another form.
  4. The user will be able to back to previous form and edit it.
  5. The buttons that it available only 2 buttons back arrow and next arrow(save data and move to another form and close current form)
  6. The last form will save all the data.
  7. When user finished all the question, the form will allows to be reopened from the first one and it will insert entirely new line of user data in table.

我所做过的是

  1. I create a form, with a box and tag, connected directly to the table, so it will updated in real time. so user can back and forth to edit it
  2. "Next" button, using macro to close and open new form.
  3. 使用降压 VB 代码更新表格的最终格式:

    Private Sub Close_Click()
    
      CurrentDb.Execute "INSERT INTO Demographics(vid, cid, dobd, gend, heght, heght2,         wgt, wgt2, lschool, secschl, qualify, hqlify, army, abranch )" & _
      "VALUES( " & vid1 & " , " & cid1 & " , " & dobd1 & " , " & gend1 & " , " & heght1 &  " , " & heght21 & " , " & wgt1 & " , " & wgt21 & " , " & lschool & " , " & secschl1 & " , "  & qualify1 & " , " & hqilfy1 & " , " & army1 & " , " & abranch1 & " )"
    
      cmdClear_Click
      cmdClose_Click
    End Sub
    
    Private Sub cmdClose_Click()
      DoCmd.Close 
    End Sub
    
    Private Sub cmdClear_Click()
      vid1 = ""
      cid1 = ""
      dobd1 = ""
      gend1 = ""
      heght1 = ""
      heght21 = ""
      wgt1 = ""
      wgt21 = ""
      lschool1 = ""
      secschl = ""
      qualify = ""
      hqlify = ""
      army = ""
      abranch = ""
    
    End Sub
    
    
    Private Sub Form_Current()
    End Sub
    

问题:

  1. Final page script above wouldnt insert the data into the table at all.
  2. It can insert data into table, if i indexed the column in the table, but it will end up messy if i did a lot of updates

我的问题:

  1. Can anyone suggest me the correct VB script to do this continuously form activity, instead of update entire table per-form.
  2. How do I create a form like in access 2003 on which i can create switchboard with login for user only, and special login access to the database only for administrator, so it will like an application. (im using Access 2010 .accdb file)

sorry for the long post, just want to make sure everything is clear, any answer would be greatly appreciated. Thank you in advance

问题回答

关于你的第一个问题:

这是约束表格可能证明有用的情况之一。

您可以使用 INSERT into ,但您需要为每个表格生成不同的查询以避免错误。如果您设置了所有表格以绑定到同一个表格,则窗体字段可以与表格直接互动,而不需要很多代码。

试用以下示例,使用 3 个表格(尽管您可以很容易地将其扩展至 30 个表格) 。

每种表格有:

  1. A hidden field, ctlID (bound to the table s ID field)
  2. Any number of other fields, bound to matching fields in the table
  3. A Next button, cmdNext (or in the case of the last form, cmdFinish)

您可以使用 There Condition 参数 DoCmd. OpenForm 来持续以多种形式引用同一记录。

这里的代码是:

  Form1 code:
Private Sub Form_Load()
    DoCmd.GoToRecord , , acNewRec
End Sub

Private Sub cmdNext_Click()
    Dim iID As Long
    iID = Me.ctlID.Value

    DoCmd.Close acForm, Me.Name
    DoCmd.OpenForm "Form2", , , "ID = " & iID
End Sub

  Form2 code:
Private Sub cmdNext_Click()
    Dim iID As Long
    iID = Me.ctlID.Value

    DoCmd.Close acForm, Me.Name
    DoCmd.OpenForm "Form3", , , "ID = " & iID
End Sub

  Form3 code:
Private Sub cmdFinish_Click()
    DoCmd.Close acForm, Me.Name
End Sub




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Outlook 2007 CommandBarControl.Execute won t work

I recently switched to Outlook 2007 and noticed that my VBA-macros won t work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

热门标签