By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,594 Members | 2,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,594 IT Pros & Developers. It's quick & easy.

Flexgrid data to access

100+
P: 153
Hi, I have today completed my first ever program for a friend which displays total hours worked for each day then adds them up.

Now I want to transfer this data to store in access. I did do a sample kind of thing last week with flexgrid which worked but i didn't write code! Itshowed me how to use this procedure but I have only gotten so far with this.

So what I have so far in flexgrid is the start time, end time and total hurs which I just want to transfer to access.

After a few hours searching I need help!

Could anyone help me please? Very limited knowledge on access but fast learner!

Thanks for reading

Brendan

Expand|Select|Wrap|Line Numbers
  1.  
  2. MSFlexGrid1.TextMatrix(1, 0) = Format((DTPickersunstart.Value), "DD-MM-YY HH:nn")
  3. MSFlexGrid1.TextMatrix(2, 0) = Format((DTPickermonstart.Value), "DD-MM-YY HH:nn")
  4. MSFlexGrid1.TextMatrix(3, 0) = Format((DTPickertuesstart.Value), "DD-MM-YY HH:nn")
  5. MSFlexGrid1.TextMatrix(4, 0) = Format((DTPickerwedsstart.Value), "DD-MM-YY HH:nn")
  6. MSFlexGrid1.TextMatrix(5, 0) = Format((DTPickerthursstart.Value), "DD-MM-YY HH:nn")
  7. MSFlexGrid1.TextMatrix(6, 0) = Format((DTPickerfristart.Value), "DD-MM-YY HH:nn")
  8. MSFlexGrid1.TextMatrix(7, 0) = Format((DTPickersatstart.Value), "DD-MM-YY HH:nn")
  9.  
  10. MSFlexGrid1.TextMatrix(1, 1) = Format((DTPickersunend.Value), "DD-MM-YY HH:nn")
  11. MSFlexGrid1.TextMatrix(2, 1) = Format((DTPickermonend.Value), "DD-MM-YY HH:nn")
  12. MSFlexGrid1.TextMatrix(3, 1) = Format((DTPickertuesend.Value), "DD-MM-YY HH:nn")
  13. MSFlexGrid1.TextMatrix(4, 1) = Format((DTPickerwedsend.Value), "DD-MM-YY HH:nn")
  14. MSFlexGrid1.TextMatrix(5, 1) = Format((DTPickerthursend.Value), "DD-MM-YY HH:nn")
  15. MSFlexGrid1.TextMatrix(6, 1) = Format((DTPickerfriend.Value), "DD-MM-YY HH:nn")
  16. MSFlexGrid1.TextMatrix(7, 1) = Format((DTPickersatend.Value), "DD-MM-YY HH:nn")
  17.  
  18. MSFlexGrid1.TextMatrix(1, 2) = Lblsunsubtotal.Caption
  19. MSFlexGrid1.TextMatrix(2, 2) = lblmonsubtotal.Caption
  20. MSFlexGrid1.TextMatrix(3, 2) = lbltuessubtotal.Caption
  21. MSFlexGrid1.TextMatrix(4, 2) = lblwedssubtotal.Caption
  22. MSFlexGrid1.TextMatrix(5, 2) = lblthurssubtotal.Caption
  23. MSFlexGrid1.TextMatrix(6, 2) = lblfrisubtotal.Caption
  24. MSFlexGrid1.TextMatrix(7, 2) = lblsatsubtotal.Caption
  25.  
  26.  
Dec 3 '07 #1
Share this Question
Share on Google+
5 Replies


Dököll
Expert 100+
P: 2,364
Hi, I have today completed my first ever program for a friend which displays total hours worked for each day then adds them up.

Now I want to transfer this data to store in access. I did do a sample kind of thing last week with flexgrid which worked but i didn't write code! Itshowed me how to use this procedure but I have only gotten so far with this.

So what I have so far in flexgrid is the start time, end time and total hurs which I just want to transfer to access.

After a few hours searching I need help!

Could anyone help me please? Very limited knowledge on access but fast learner!

Thanks for reading

Brendan

Expand|Select|Wrap|Line Numbers
  1.  
  2. MSFlexGrid1.TextMatrix(1, 0) = Format((DTPickersunstart.Value), "DD-MM-YY HH:nn")
  3. MSFlexGrid1.TextMatrix(2, 0) = Format((DTPickermonstart.Value), "DD-MM-YY HH:nn")
  4. MSFlexGrid1.TextMatrix(3, 0) = Format((DTPickertuesstart.Value), "DD-MM-YY HH:nn")
  5. MSFlexGrid1.TextMatrix(4, 0) = Format((DTPickerwedsstart.Value), "DD-MM-YY HH:nn")
  6. MSFlexGrid1.TextMatrix(5, 0) = Format((DTPickerthursstart.Value), "DD-MM-YY HH:nn")
  7. MSFlexGrid1.TextMatrix(6, 0) = Format((DTPickerfristart.Value), "DD-MM-YY HH:nn")
  8. MSFlexGrid1.TextMatrix(7, 0) = Format((DTPickersatstart.Value), "DD-MM-YY HH:nn")
  9.  
  10. MSFlexGrid1.TextMatrix(1, 1) = Format((DTPickersunend.Value), "DD-MM-YY HH:nn")
  11. MSFlexGrid1.TextMatrix(2, 1) = Format((DTPickermonend.Value), "DD-MM-YY HH:nn")
  12. MSFlexGrid1.TextMatrix(3, 1) = Format((DTPickertuesend.Value), "DD-MM-YY HH:nn")
  13. MSFlexGrid1.TextMatrix(4, 1) = Format((DTPickerwedsend.Value), "DD-MM-YY HH:nn")
  14. MSFlexGrid1.TextMatrix(5, 1) = Format((DTPickerthursend.Value), "DD-MM-YY HH:nn")
  15. MSFlexGrid1.TextMatrix(6, 1) = Format((DTPickerfriend.Value), "DD-MM-YY HH:nn")
  16. MSFlexGrid1.TextMatrix(7, 1) = Format((DTPickersatend.Value), "DD-MM-YY HH:nn")
  17.  
  18. MSFlexGrid1.TextMatrix(1, 2) = Lblsunsubtotal.Caption
  19. MSFlexGrid1.TextMatrix(2, 2) = lblmonsubtotal.Caption
  20. MSFlexGrid1.TextMatrix(3, 2) = lbltuessubtotal.Caption
  21. MSFlexGrid1.TextMatrix(4, 2) = lblwedssubtotal.Caption
  22. MSFlexGrid1.TextMatrix(5, 2) = lblthurssubtotal.Caption
  23. MSFlexGrid1.TextMatrix(6, 2) = lblfrisubtotal.Caption
  24. MSFlexGrid1.TextMatrix(7, 2) = lblsatsubtotal.Caption
Hello Brendan!

Welcome to The Scripts...

You would have eventually found this. But here's an example that should help you add to an access database:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub SubmitToAccess_Click()   'this funtion will load entry to database
  3.  
  4.         Dim my_database As Database
  5.         Set my_database = OpenDatabase("C:\DataMining\Data_Central.mdb")
  6.         my_database.Execute "insert into Data_Central.Employee(UserID, EmployeeID, TodayDate, DOB,Title,Fname,Mname,Lname,Suffix, Address1,Address2,City,State,PostalCode,Country,Gender,MaritalStatus,HomePhone,MobilePhone,Fax,Email,LicenseNum,Day,Month,Year,County) Values('" & Text1(0).Text & "','" & Text1(1).Text & "' , '" & Text1(2).Text & "' , '" & Text1(3).Text & "','" & Text1(4).Text & "' , '" & Text1(5).Text & "' ,'" & Text1(6).Text & "' ,'" & Text1(7).Text & "' ,'" & Text1(8).Text & "' ,'" & Text1(9).Text & "' ,'" & Text1(10).Text & "' ,'" & Text1(11).Text & "' ,'" & Text1(12).Text & "','" & Text1(13).Text & "' ,'" & Text1(14).Text & "' ,'" & Text1(15).Text & "' ,'" & Text1(16).Text & "' ,'" & Text1(17).Text & "' ,'" & Text1(18).Text & "' ,'" & Text1(19).Text & "' ,'" & Text1(20).Text & "' ,'" & Text1(21).Text & "' ,'" & Text1(22).Text & "','" & Text1(23).Text & "','" & Text1(24).Text & "','" & Text1(25).Text & "')"
  7.         my_database.Close
  8.     R_Click
  9.  
  10. End Sub
  11.  
  12.  
I copied and paste from an application example built for class ages ago:

(1) UserID, EmployeeID, TodayDate and so on are fields your access database should have.

(2) & Text1(0).Text & "','" & Text1(1).Text & "' , '" & Text1(2).Text & "' , '" & Text1(3).Text & "', are fields on your VB form. So what ever Flexgrid added to your form you can send to access. In which case you'd need Label1(0), and so on instead of Text1(0)...

Please tell us if this works, and stay tuned for added support if needed.

In a bit, Brendan!

Dököll
Dec 3 '07 #2

9815402440
100+
P: 180
hi


try this

dim rst as new adodb.recordset
dim cnn as new adodb.connection

with cnn
.Provider = "MsDataShape"
.Properties("Data Provider") = "Microsoft.Jet.OLEDB.4.0"
.Properties("Data Source") = "c:\Data.mdb"
.Open

end with
rst.Open "select * from table",cnn
dim i as integer
with flexGrid
for i = .fixedrows to .rows-1
rst.addnew
rst.fields("field0").value = .textmatrix(i,0)
rst.fields("field1").value = .textmatrix(i,1)
'''' and so on
next
end with
rst.update


regards
manpreet singh dhillon hoshiarpur
Dec 3 '07 #3

100+
P: 153
Thanks People,

I need To go out so ill try this afternoon,

Thanks again,

Any input on how to add fields in access would be helpful, I read somewhere it has to be converted to access 97 file???

Brendan
Dec 3 '07 #4

100+
P: 153
I'm not understanding this very well, like whats my_database? Is that a name for a control I need to add, Ireally am a novice at this and if you have the time a little slower and i'll be flying!!

I'll keep trying to save your time.

Thanks

Brendan
Dec 3 '07 #5

100+
P: 153
Solved - Thanks for initial input

Brendan
Dec 3 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.