Im making a program at the moment which should be able to create (or load) a database, then edit it from the users input - sort of like an order form type of thing.
I Used excel for my database - against the advice of my teacher who likes Access, but i was unable to use it at the time - and have been able to manage to get by so far, however now i keep getting a "ComException was unhandled" Error.
Expand|Select|Wrap|Line Numbers
- Private Sub DBASEdefaultVals()
- For i = 2 To 61 Step 11
- xlSheet.Cells(i, 1).value = "Depot " + CStr(i)
- xlSheet.Cells(i + 1, 1).Value = "TYPE A"
- xlSheet.Cells(i + 2, 1).Value = "TYPE B"
- xlSheet.Cells(i + 3, 1).Value = "TYPE C"
- xlSheet.Cells(i + 4, 1).Value = "TYPE D"
- xlSheet.Cells(i + 5, 1).Value = "TYPE E"
- xlSheet.Cells(i + 6, 1).Value = "TYPE F"
- xlSheet.Cells(i + 7, 1).Value = "TYPE G"
- xlSheet.Cells(i + 8, 1).Value = "TYPE H"
- xlSheet.Cells(i + 9, 1).Value = "TYPE I"
- xlSheet.Cells(i + 10, 1).Value = "TYPE J"
- Next
- xlSheet.Cells(1, 1).Value = "DATE"
- 'Figures out the number of days in the user indicated amount of years by subtracting the current date from the date as it will be in the specified amount of years
- TSDayRec = DateTime.Today.AddYears(YearsToLog) - DateTime.Today
- IntDayRec = TSDayRec.Days
- For i = 1 To IntDayRec
- xlSheet.Cells(1, i + 1).value = DateTime.Today.AddDays(i)
- For a = 1 To 10
- xlSheet.Cells(2 + a, i + 1).value = QtyDepot1(a)
- xlSheet.Cells(13 + a, i + 1).value = QtyDepot2(a)
- xlSheet.Cells(24 + a, i + 1).value = QtyDepot3(a)
- xlSheet.Cells(35 + a, i + 1).value = QtyDepot4(a)
- xlSheet.Cells(46 + a, i + 1).value = QtyDepot5(a)
- Next
- Next
- End Sub
Also another small problem, i have a SaveFileBox where the user indicates a place to svae the file, and the database is saved at that location. Ive got teh box working fine, im jsut a bit lost of how to save the file at that spot.
Expand|Select|Wrap|Line Numbers
- Private Sub SaveDatabase()
- SaveFileDialog1.ShowDialog()
- WhatFile = SaveFileDialog1.FileName
- If My.Computer.FileSystem.FileExists(WhatFile) Then
- intReply = MsgBox(WhatFile & " already exists. Would you like to overwrite it?", YesNoCancel Or Exclamation, "Overwrite File?")
- If intReply = 2 Then
- Exit Sub
- ElseIf intReply = 6 Then
- xlBook.SaveAs(WhatFile)
- Label6.Text = "Successfully Saved"
- ElseIf intReply = 7 Then
- SaveDatabase()
- End If
- End If
- End Sub