VB code in form

  • Thread starter Thread starter ScrewzLews
  • Start date Start date
S

ScrewzLews

Guest
I have a form called "testnumber". The form allows me to fill in information ona new project. Then upon hitting the "request new testnumber" button, the event goes into a VB module. This DB was not written by me, and is too complex for my tastes, however, I understand enough to see all the actions which are supposed to take place. The way the VB script is supposed to run is that it goes out to the "table in question" searches for a list of testnumbers using a date method. hen it performs a "count +1" and places the next possible occurring testnumber in a field on the form. Once the form is completed then another button is used to import all fields on the form into the table. My problem, is suddenly the testnumbers are coming up all out of order or duplicated. The code looks fine but I don't know VB. This seems like it would be a relatively easy script to implement but what do I know? Anyone want to tackle this one? Here is the code for the event::

Private Sub Command97_Click()
'SendKeys "+{f9}"
Dim Count As Integer
Dim MyDB As Database, MyTable As Recordset
Dim D As TextBox


Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MyTable = MyDB.OpenRecordset("LOG", DB_OPEN_TABLE)


MyTable.MoveFirst

Do Until MyTable.EOF
If MyTable!DATE = DATE Then
Count = Count + 1

End If
MyTable.MoveNext

Loop

'MyTable.MoveLast
'If MyTable!Date = Date Then ' Check Validity of Record to be Added
' If MyTable![TEST NUMBER] < Count + 1 Then 'Check of Validity

' MyTable.AddNew 'Prepare to Add New Record
' D = Date
' MyTable![TEST NUMBER] = Date
'& (Count + 1)
' MyTable.Update
' Forms![Log].TESTNUMBER = Date
'& (Count + 1)

'End If
Dim tempdate
'tempdate = Format(Date, ["000000"])

'tempdate = Format(Date, "#c#ccc")
[TESTNUMBER] = DATE & "." & (Count + 2)




MyTable.Close
MyDB.Close

[This message has been edited by ScrewzLews (edited 08-02-2001).]
 
Thanks...was in the middle of editing the message when I lost service...it's posted in the original message now.

Pete
 

Users who are viewing this thread

Back
Top Bottom