programmatically login

H

hommer

Hi, Access experts,

I have this vb6 code that I tried to convert to vb.net 2003.
There is this access mdb app that is shared by users and other vb apps. When
users run it, it presents the normal login form and do the authentication.
When it is called up by another app, the old vb code made it bypass the login
part.

Here is the old vb (or VBA) code:
Public Sub CloseForms(objAccess As Access.Application)
Do While objAccess.Forms.Count > 0
objAccess.DoCmd.OpenForm objAccess.Forms(0).Name, acViewDesign
objAccess.DoCmd.Close acForm, objAccess.Forms(0).Name, acSaveNo
Loop
End Sub

And here is my dot net code. It does not work. The Access log in form still
presents itself. Am I on the right track?

Private Sub btnViewInvoice_click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnViewInvoice.Click
'testing to host an access report here
Dim strWhere As String '= "[INVOICE_NO]='572770'"
If txtInvoice.Text = String.Empty Then
strWhere = "[INVOICE_NO]='" & InputBox("Please enter the
Invoice No.", "User Input") & "'"
Else
strWhere = "[INVOICE_NO]='" & txtInvoice.Text & "'"
End If
Dim acc_App As Access.Application = New Access.Application
' or
' Dim acc_App As Access.Application =
CreateObject("Access.Application")
Try
acc_App.OpenCurrentDatabase("C:\OPDATA\Invoice_Print.mdb",
True)
'when using above live one, need find a way to bypass login
acc_App.Visible = True
Do While acc_App.Forms.Count > 0
acc_App.DoCmd.OpenForm(acc_App.Forms(0).Name,
Access.AcFormView.acDesign)
acc_App.DoCmd.Close(Access.AcObjectType.acForm,
acc_App.Forms(0).Name, Access.AcCloseSave.acSaveNo)
Loop

acc_App.DoCmd.OpenReport("rptCustInvoice",
Access.AcView.acViewPreview, , strWhere)

Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

By the way, I have set reference to MS Access 11.0 Type Library in my dotnet
project.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top