Ms access to Vb.net

anishkgt

Member
Joined
Jan 31, 2015
Messages
16
Programming Experience
Beginner
Hi all,

I've managed to create an ms access application. i wish to do this in Vb.net with MS Visual Studio. Would that be possible. I've tried a bit but the codes are different.
 
Of course it's possible but there's no simple conversion routine you can run to do it for you. If you want to build a VB.NET application then you need to learn how to build a VB.NET application and then do so. It won't be the same as an Access application but there will be some similarities, in principle at least. If you don't know how VB.NET works then you might follow the Tutorial link in my signature below. There is also the Data Walkthroughs link, which will provide some examples specific to Access.
 
Hi jmcilhinney.
Thanks for the reply. Your links did help me get started. Was creating a form to search a query in Ms access. Manged to do all but a little in doubt about the below code. all works well but do not wish to display the data as soon as the form load

VB.NET:
Public Class frmInvoice
    Private Sub frmInvoice_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Backup_GAPDataSet.qryInvoice' table. You can move, or remove it, as needed.
        'Me.QryInvoiceTableAdapter.Fill(Me.Backup_GAPDataSet.qryInvoice)

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.QryInvoiceBindingSource.Filter = "MIRCrDate = '" & Me.txtDate.Text & "'"
    End Sub
End Class
so i've amended it as below is that correct

VB.NET:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.QryInvoiceBindingSource.Filter = "MIRCrDate = '" & Me.txtDate.Text & "'"
        Me.QryInvoiceTableAdapter.Fill(Me.Backup_GAPDataSet.qryInvoice)
    End Sub

i do get the result i want but just curious i am on the correct path :)
 
i do get the result i want but just curious i am on the correct path :)
That looks like a good start, but you should probably not reload data from database each time button is clicked. Instead you can load the data in background once form loads.
    Private Sub frmInvoice_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        GetDataAsync()
    End Sub

    Private Async Sub GetDataAsync()
        Await Task.Run(Function() Me.QryInvoiceTableAdapter.Fill(Me.Backup_GAPDataSet.qryInvoice))
    End Sub

As long as BindingSource.ResetBindings is not called after the awaited Fill here, the unfiltered data should not display when form first loads.
In button click you then only need to set BindingSource.Filter.
 
Tried
VB.NET:
 GetDataAsync()
gave an error " 'GetDataAsync' is not declared. It may be inaccessible due to its protection level. "
 
Tried
VB.NET:
 GetDataAsync()
gave an error " 'GetDataAsync' is not declared. It may be inaccessible due to its protection level. "
As you can see it is declared. Perhaps your forum profile is wrong when saying you use .Net 4.5 ? There are of course other ways to perform async operations in older .Net frameworks.
 
Ahmmmm ! didn't know what put in since am not much of a "Programming guy". sorry about that and how do i correct it ?
 
Hi jmcilhinney,

without the filter shows all the data how can i stop it from loading when the form loads and rather display them as the text box is filled-in.
 
Ahmmmm ! didn't know what put in since am not much of a "Programming guy". sorry about that and how do i correct it ?
Settings (top-right menu) > Edit Profile (left menu).
 
Hi jmcilhinney,

without the filter shows all the data how can i stop it from loading when the form loads and rather display them as the text box is filled-in.
Change load call to:
Threading.ThreadPool.QueueUserWorkItem(AddressOf GetData)

change GetDataAsync method to
Private Sub GetData(state As Object)
    Me.QryInvoiceTableAdapter.Fill(Me.Backup_GAPDataSet.qryInvoice)
End Sub
 
Hi JohnH,
tried your code here as shown below
VB.NET:
Public Class frmSearch

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Backup_GAPDataSet.qryMIR' table. You can move, or remove it, as needed.
        'Me.QryMIRTableAdapter.Fill(Me.Backup_GAPDataSet.qryMIR)
        [COLOR=#ff0000]Threading.ThreadPool.QueueUserWorkItem(AddressOf GetData)[/COLOR]
    End Sub
   [COLOR=#ff0000] Private Sub GetData(state As Object)
        Me.QryMIRTableAdapter.Fill(Me.Backup_GAPDataSet.qryMIR)
    End Sub[/COLOR]
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        txtTicket.Text = ""
        txtPNR.Text = ""
    End Sub

    Private Sub txtPNR_TextChanged(sender As Object, e As EventArgs) Handles txtPNR.TextChanged
        Me.QryMIRBindingSource.Filter = "PNR Like '%" & Me.txtPNR.Text & "%'"
    End Sub

    Private Sub txtTicket_TextChanged(sender As Object, e As EventArgs) Handles txtTicket.TextChanged
        Me.QryMIRBindingSource.Filter = "TicketNumber Like '%" & Me.txtTicket.Text & "%'"
    End Sub
End Class
the form opens up faster without loading the data but as i type into the text box nothing happens.
 
the form opens up faster without loading the data but as i type into the text box nothing happens.
I don't know about your filter expression, but same code just setting a relevant filter works as expected here.
 
Hi JohnH,

i've managed to change how the form loads. The form loads fast as the FILL is not used and moved that to a button when clicked populates the whole database. I know thats kinda stupid to do as the db grows its going to be a problem. On my access VBA i've used a date range to avoid the whole DB from loading, need to check on the VB.net for the date range code. Any ideas on it !
 
Back
Top