# 请教这个程式错在什么?

Posted by kkcheung on June 04, 1999 at 11:48:41:

Private Sub Form_Load()
Public horse_no As Integer, DB As Database, RS As Recordset
Public p_win As Single, temp_rs As Recordset, temp_winpay As Integer, temp_p_pay As Integer, temp_step As Integer, temp_step2 As Integer, temp_post As Integer
Private Sub Form_Load()

Set DB = OpenDatabase("C:\RACE\RACE.MDB")
Set RS = DB.OpenRecordset("horse", dbOpenDynaset)Dim temp_winpay As Integer, temp_p_pay As Integer, temp_step As Integer, temp_step2 As Integer, temp_post As Integer

For i = 1 To 10
temp_winpay = Int(Rnd(2) * 100)
temp_p_pay = Int(Rnd(2) * 100)
temp_step = Int(Rnd(2) * 10)
temp_step2 = temp_step
temp_post = temp_step
Addrs RS, temp_winpay, temp_p_pay, temp_step, temp_step2, temp_post
Next
End Sub
Function Addrs(temp_rs As Recordset, temp_winpay As Integer, temp_p_pay As Integer, temp_step As Integer, temp_step2 As Integer, temp_post As Integer)

With temp_rs
.AddNew <==============执行时在这里出错!
!horse_no = temp_winpay
!w_pay = temp_p_pay
!step1 = temp_step
!step2 = temp_step
!postion = temp_step
.Update
.Bookmark = .LastModified
End With
End Function

执行后出现"执行期错误 91",没有设定物件变数或with区块变数.
上面的程式,是否可以再简单一此

Follow Ups:

- 程式是不容易看出系统问题, 只能找逻辑问题, 试一试 ... 安宝 13:30:22 6/04/99 (0)