hey I have a dynamic array which holds records, which is fine for viewing records(previous and next) when data has been added - but when the program is closed and restarted all the data is (of course) lost from the array.
I want to therefor add the data added to a file as soon as it's submitted.
my:
put #FilNo, lastrec, RecordArray(lastrec)
does not work...what am i doing wrong?
here's my code if u want more information
all suggestions are VERY welcome and appreciated!
cheers
JoE
---------------module-----------
Option Explicit
Public Type tStorage
Type As String * 30
Date As Date
FromTo As String * 20
Quantity As Integer
JobNum As Integer
EmpNum As Integer
RecSent As Boolean
End Type
Public Record As tStorage
Public RecLen As Integer
Public CurrentRec As Integer
Public LastRec As Integer
Public FileNo As Integer
Public RecordArray() As tStorage
------------------form-------------
Public Sub cmdSubmit_Click()
LastRec = LastRec + 1
Dim i As Integer
i = LastRec
ReDim Preserve RecordArray(i)
RecordArray(i).Date = txtDate.Text
RecordArray(i).EmpNum = txtEmpNum.Text
RecordArray(i).FromTo = txtFromTo.Text
RecordArray(i).JobNum = txtJobNum.Text
RecordArray(i).Quantity = txtQuant.Text
RecordArray(i).Type = cmbType.Text
Call Adder
MsgBox "Record Added!", vbExclamation + vbOKOnly
Call Clear
End Sub
Public Sub Adder()
Put FileNo, LastRec, RecordArray(LastRec)
End Sub
Private Sub Form_Load()
Dim i As Integer
FileNo = FreeFile
RecLen = Len(Record)
Open App.Path & "\storage.dat" For Random As FileNo Len = RecLen
LastRec = LOF(FileNo) / RecLen
ReDim RecordArray(LastRec)
For i = 1 To LastRec
Get #FileNo, i, RecordArray(i)
Next
Close FileNo
End Sub
Private Sub View()
txtDate.Text = RecordArray(CurrentRec).Date
txtEmpNum.Text = RecordArray(CurrentRec).EmpNum
txtFromTo.Text = RecordArray(CurrentRec).FromTo
txtJobNum.Text = RecordArray(CurrentRec).JobNum
txtQuant.Text = RecordArray(CurrentRec).Quantity
cmbType.Text = RecordArray(CurrentRec).Type
End Sub
I want to therefor add the data added to a file as soon as it's submitted.
my:
put #FilNo, lastrec, RecordArray(lastrec)
does not work...what am i doing wrong?
here's my code if u want more information
all suggestions are VERY welcome and appreciated!
cheers
JoE
---------------module-----------
Option Explicit
Public Type tStorage
Type As String * 30
Date As Date
FromTo As String * 20
Quantity As Integer
JobNum As Integer
EmpNum As Integer
RecSent As Boolean
End Type
Public Record As tStorage
Public RecLen As Integer
Public CurrentRec As Integer
Public LastRec As Integer
Public FileNo As Integer
Public RecordArray() As tStorage
------------------form-------------
Public Sub cmdSubmit_Click()
LastRec = LastRec + 1
Dim i As Integer
i = LastRec
ReDim Preserve RecordArray(i)
RecordArray(i).Date = txtDate.Text
RecordArray(i).EmpNum = txtEmpNum.Text
RecordArray(i).FromTo = txtFromTo.Text
RecordArray(i).JobNum = txtJobNum.Text
RecordArray(i).Quantity = txtQuant.Text
RecordArray(i).Type = cmbType.Text
Call Adder
MsgBox "Record Added!", vbExclamation + vbOKOnly
Call Clear
End Sub
Public Sub Adder()
Put FileNo, LastRec, RecordArray(LastRec)
End Sub
Private Sub Form_Load()
Dim i As Integer
FileNo = FreeFile
RecLen = Len(Record)
Open App.Path & "\storage.dat" For Random As FileNo Len = RecLen
LastRec = LOF(FileNo) / RecLen
ReDim RecordArray(LastRec)
For i = 1 To LastRec
Get #FileNo, i, RecordArray(i)
Next
Close FileNo
End Sub
Private Sub View()
txtDate.Text = RecordArray(CurrentRec).Date
txtEmpNum.Text = RecordArray(CurrentRec).EmpNum
txtFromTo.Text = RecordArray(CurrentRec).FromTo
txtJobNum.Text = RecordArray(CurrentRec).JobNum
txtQuant.Text = RecordArray(CurrentRec).Quantity
cmbType.Text = RecordArray(CurrentRec).Type
End Sub