jo15765
04-03-2012, 06:16 PM
I am running the EXACT same Procedure but with two different names. Let's call it procedure1 and procedure2. Procedure1 is set up like this
Sub Procedure1(AHName As String)
sql = "Select * FROM tbl_Uno"
Set cn = New ADODB.Connection
cn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=P:\Database\Test\" & AHName & "\\" & AHName & ".mdb;"
And Procedure 2
Sub Procedure2()
txtAHName = UserForm1.txt1.Text
sql = "Select * FROM tbl_Uno"
Set cn = New ADODB.Connection
cn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=P:\Database\Test\" & txtAHName & "\\" & txtAHName & ".mdb;"
As you can see they both run the same SQL procedure, but one gets the variable passed from the main procedure whereas the other gets the variable passed from the value of a textbox. Is there a way to combine those two procedures and say that if the value passed from the main procedure is null, THEN check the value of the textbox if they are both null then exit procedure (I'm assuming that piece would be Resume Next).
Sub Procedure1(AHName As String)
sql = "Select * FROM tbl_Uno"
Set cn = New ADODB.Connection
cn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=P:\Database\Test\" & AHName & "\\" & AHName & ".mdb;"
And Procedure 2
Sub Procedure2()
txtAHName = UserForm1.txt1.Text
sql = "Select * FROM tbl_Uno"
Set cn = New ADODB.Connection
cn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=P:\Database\Test\" & txtAHName & "\\" & txtAHName & ".mdb;"
As you can see they both run the same SQL procedure, but one gets the variable passed from the main procedure whereas the other gets the variable passed from the value of a textbox. Is there a way to combine those two procedures and say that if the value passed from the main procedure is null, THEN check the value of the textbox if they are both null then exit procedure (I'm assuming that piece would be Resume Next).