Display a market in access form

Please post any questions regarding the program here.

Moderator: 2020vision

Display a market in access form

Postby Tradyann » Fri Nov 23, 2012 4:39 pm

Hello,

I try to use Access for placing bets.

i.e. I know the market ID : 107524186 (input in MarketId.Text box)

I can open this market with this code :
Code: Select all
Private Sub OpenMarketButton_Click()
    If ba Is Nothing Then
        Set ba = New BettingAssistantCom.ComClass
    End If
               MarketId.SetFocus
   
                result = ba.openMarket(MarketId.Text, 1)

    ba.refreshRate = 1
End Sub


But i would like to have all selections displayed in this form.
I have created text's boxes (selection0 selection1...etc)
This code doesn't work :

Code: Select all
Private Sub ba_pricesUpdated()
   
Dim priceItem As Variant
Dim prices As Variant
Dim i As Integer

    prices = ba.getPrices
   
    i = 0
    For Each priceItem In prices
       
    i = i + 1
   
    Selection(i).SetFocus
    Selection(i).Text = priceItem(i).Selection
       
    Next
   
End Sub


Thanks for your help
User avatar
Tradyann
 
Posts: 139
Joined: Thu Dec 15, 2011 7:13 pm

Postby negapo » Fri Nov 23, 2012 5:30 pm

Tradyann, i have used access and BA Com a long time ago. I do not recall much from the COM. Where does your code stops?
I can see something strange in your code.
You cannot reference TextBoxes on a form without explicitly naming them (at least in Access 2003). So you cannot use the code Selection(i), you have to put Selection1, etc.
What you can do is dump the prices on a table and then make a continuous form to show the data.

Or you can do something like this:


Code: Select all
Private Sub ba_pricesUpdated()
Dim priceItem As Variant
Dim prices As Variant
Dim i As Integer, CurrentTextBox As TextBox

    prices = ba.getPrices
    i = 0
    For Each priceItem In prices
       
        i = i + 1
       
        Select Case i
            Case 1
                CurrentTextBox = Me.Selection1
            Case 2
                CurrentTextBox = Me.Selection2
            Case 3
                CurrentTextBox = Me.Selection3
        End Select
        CurrentTextBox.SetFocus
        CurrentTextBox.Text = priceItem(i).Selection
       
    Next
   
End Sub

This suggestion doesn't take into account the variable number of selections so it's a little bit dirty.
You don't need the SetFocus also, you can remove it.
negapo
 
Posts: 179
Joined: Thu Mar 19, 2009 1:17 pm
Location: Porto, Portugal

Postby Tradyann » Sun Nov 25, 2012 11:46 am

Ok I use this code now :

Code: Select all
Private Sub ba_pricesUpdated()
   
Dim prices As Variant

    prices = ba.getPrices

    For i = 0 To UBound(prices)
   
    Select Case i
           
    Case 0
    Selection0.Value = prices(0).Selection
   
    Case 1
    Selection1.Value = prices(1).Selection
   
    Case 2
    Selection2.Value = prices(2).Selection
   
    Case 3
    Selection3.Value = prices(3).Selection
   
    ' etc ....
   
    End Select
   
    Next i
   
End Sub
User avatar
Tradyann
 
Posts: 139
Joined: Thu Dec 15, 2011 7:13 pm


Return to Help

Who is online

Users browsing this forum: Bing [Bot] and 63 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.