Results 1 to 10 of 10

Thread: flexgrid with Access

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    flexgrid with Access

    Hi
    I have a MSFlexgrid inside my VB6 form.The backend is Access 2003.This flexgrid contains 144 rows and 1 column Room1:The Flexgrid looks like:
    Intervals Room1
    06.00 to 06.10
    06.10 to 06.20
    06.20 to 06.30
    06.30 to 06.40
    ...and so on covering the 24 hours

    If a client wants to book the Room1 between 06.00 to 06.30 then I add a record to a table "Book" in which I enter all the information about the client and I add the Intervals' ID to a table "Intervallist" that has 3 fields:
    ID-Autonumber
    RId-The record ID of the record just added(containing the informations about the client)
    IntervalID-The intervals ID(e.g if the user wants to book the room between 06.00 to 06.30 then suppose that 06.00 to 06.10 has an ID of 7,06.10 to 06.20 has an ID of 8 and 06.20 to 06.30 has an ID of 9 then if Rid=24
    then I should add to intervallist
    Autonumber 24 7
    Autonumber 24 8
    Autonumber 24 9

    Suppose that the user changes his mind and He want to book the room between 06.00 to 06.50 what's the best way to edit the intervallist table?
    My method was to delete all the records in Intervallist that has a RID=24 and then reenter the new intervals' ID with their corresponding RID,but this method causes to me a lot of Problems.

    Can anyone help me because it's extremely urgent
    thanks in advance

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: flexgrid with Access

    I would change the table design.. unless all the possible intervals are in the database (which would be a waste of space for unused ones), it would make more sense to simply store the Start and End time of each booking.

    That way you only use one record per booking (which is all that is really needed), so is much easier to change.

    As far as I see it, you need a table which contains Room info, and a table which contains Booking info - which would contain a reference to Room, and the start & end times (with date). Your interface wouldn't need to change (but could if you wanted to).


    If you want to correct what you have, we'll obviously need to see the code to be able to say what you are doing wrong.

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: flexgrid with Access

    By using a subform with a table displayed in data entry view you can duplicate a flex grid but with more flexibility in Access by using an exact version of a table view.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Re: flexgrid with Access

    RobDog888 I didn't catch ur proposition
    Well my code is
    suppose that the starting date is 06.00
    sint=06.00
    BInterval contains all the intervals with their ID
    ID Interval
    1 06.00 to 06.10
    2 06.10 to 06.20
    3 06.20 to 06.30
    4 06.30 to 06.40
    VB Code:
    1. rs.Open "Select * from BInterval where Left(BInterval,5) = " & sint, cn, adOpenKeyset, adLockPessimistic
    2. nc = rs.Fields(0) 'so in this case nc=1
    3. rs.Close
    4.  
    5. int contains the number of intervals,e.g If the user wants to book the room between 06.00 to 06.20 so we have 2 intervals(06.00 to 06.10 and 06.10 to 06.20) so int=2
    6.  
    7. rs5.open"Select * from intervallist",cn,adopenKeyset,adlockpessimistic
    8. For i = 0 To int
    9. rs5.AddNew
    10. rs5.Fields("BID") = nar 'nar is the ID of the record containing the client information
    11. rs5.Fields("BIntID") = nc + i
    12. Next i
    13. End If

    What's wrong with this?
    thanks

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: flexgrid with Access

    Like this.
    Attached Images Attached Images  
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Re: flexgrid with Access

    Si-the-Geek my method causes to me a lot of problems so I decided to adopt your method,so when the user chooses to book the room from 06.10 to 07.30 and 06.10's ID=2 and 07.30's ID=9 then I will send 2 fields into my table
    Starting time=2 (2 is the ID of 06.10)
    Ending time=9(9 is the ID of 07.30)

    After that the Flexgrid should display the new entered book(from 06.10 to 07.30)
    The Flexgrid look like
    Interval Room
    06.00 to 06.10
    06.10 to 06.20
    06.20 to 06.30
    06.30 to 06.40
    06.40 to 06.50
    06.50 to 07.00
    07.00 to 07.10
    07.10 to 07.20
    07.20 to 07.30

    So the flexgrid should highlight in red all the following cells:06.10 to 06.20
    06.20 to 06.3, 06.30 to 06.40, 06.40 to 06.50, 06.50 to 07.00,07.00 to 07.10,07.10 to 07.20,07.20 to 07.30

    How can I do it?
    thanks in advance

  7. #7
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: flexgrid with Access

    VB Code:
    1. For i = 1 To 10 'The row numbers from which row to which row to be highlighted
    2.         MSFlexGrid1.Col = 1 'Your column which has got the interval
    3.         MSFlexGrid1.Row = i
    4.         MSFlexGrid1.CellForeColor = vbRed 'to change the font color in red
    5.     Next
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Re: flexgrid with Access

    ganeshmoorthy I want to highlight cells have a rowdata between 2 different values
    thanks

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: flexgrid with Access

    Then simply loop thru the rows, and colour them if the rowdata is apt.

    eg:
    VB Code:
    1. With MSFlexGrid1
    2.     For i = .FixedRows To .Rows -1
    3.       If .RowData(i) >= [u]LowVal[/u] And .RowData(i) <= [u]HighVal[/u] Then
    4.         .Col = 1
    5.         .Row = i
    6.         .CellForeColor = vbRed
    7.       End If
    8.     Next
    9.   End With

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Re: flexgrid with Access

    Thanks Si_the_Geek

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width