i simple made one funciton in a module .here is the code what i have written in a module.
Code:
Code:Function GetconnectionString() As String ' The result needs to be a string !!! Dim con As ADODB.Connection Set con = New ADODB.Connection con.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=\\asfserver\itp$\Product_tabletest.mdb") GetconnectionString = "providwer=Microsoft.jet.OLEDB.4.0;" End Function
and Now i want to call GetconnectionString in form1.but it is not working.
here is the code what i have written in a form1
Code:
when i remove commented line and comment to con.connectionstrin=getconnectionstring() it is working fine.but i want to hardcode the path in module function. i don'tCode:Private Sub Form_Load() Combo1.AddItem "Production Consumable" Combo1.AddItem "Maintenance Consumable" Combo1.AddItem "Tools Consumable" Set con = New ADODB.Connection 'con.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=\\asfserver\itp$\Product_tabletest.mdb") 'Label10.Caption = Date con.ConnectionString = GetconnectionString() Label10.Caption = Format$(Now, "dddd, d mmmm yyyy") Text1.CausesValidation = True End Sub
Know why it is not working .can anybody help me.any help would be greately appreciated.




Reply With Quote