Help with logic

  • Thread starter Thread starter T
  • Start date Start date
T

T

Can someone help me on this? I have a form with a
button. When someone presses the bitton another form
opens up which asks the person to select a drive they want
to use to download a txt file. After they insert a drive
letter and select ok then it should pass that vai\riable
to the main form for it to continue downloading. here is
my cod from the main then the drive form.

Private Sub drive_Click()
On Error GoTo Err_drive_Click

DoCmd.OpenForm "frmDataDrive", , , , , acDialog
Dim fDrive1 As Variant
fDrive1 = Forms!frmDataDrive!txtDrive

DoCmd.Hourglass True
DoCmd.TransferText
acImportDelim, "", "tblPeopleData", "fdrive1://tblPeopleDat
a.txt", True, ""
DoCmd.Hourglass False
Exit_drive_Click:
Exit Sub
Err_drive_Click:
MsgBox Error$
Exit Sub
End Sub

Private Sub cmdOK_Click()
On Error GoTo cmdOk_Click_Err

Forms![frmDataDrive].Visible = False

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria

cmdOk_Click_Exit:
Exit Sub
cmdOk_Click_Err:

Resume cmdOk_Click_Exit
End Sub


Thanks for any suggestions
 
Are you keeping frmDataDrive open after the user enters the drive letter?
Instead of closing that form, assuming that you're using a command button to
let the user indicate that the drive letter has been entered, just make the
form invisible. Then your posted code can read the value from that form.
Your posted code then needs an additional step after reading that value so
that the second form is closed:

DoCmd.Close acForm, "frmDataDrive"
 
Thanks I thought I placed that in there.

My problem is

acImportDelim, "", "tblPeopleData", "fdrive1://tblPeopleDat
a.txt", True, ""

Can a variable be passed to this string?

-----Original Message-----
Are you keeping frmDataDrive open after the user enters the drive letter?
Instead of closing that form, assuming that you're using a command button to
let the user indicate that the drive letter has been entered, just make the
form invisible. Then your posted code can read the value from that form.
Your posted code then needs an additional step after reading that value so
that the second form is closed:

DoCmd.Close acForm, "frmDataDrive"

--

Ken Snell
<MS ACCESS MVP>

T said:
Can someone help me on this? I have a form with a
button. When someone presses the bitton another form
opens up which asks the person to select a drive they want
to use to download a txt file. After they insert a drive
letter and select ok then it should pass that vai\riable
to the main form for it to continue downloading. here is
my cod from the main then the drive form.

Private Sub drive_Click()
On Error GoTo Err_drive_Click

DoCmd.OpenForm "frmDataDrive", , , , , acDialog
Dim fDrive1 As Variant
fDrive1 = Forms!frmDataDrive!txtDrive

DoCmd.Hourglass True
DoCmd.TransferText
acImportDelim, "", "tblPeopleData", "fdrive1://tblPeopleDat
a.txt", True, ""
DoCmd.Hourglass False
Exit_drive_Click:
Exit Sub
Err_drive_Click:
MsgBox Error$
Exit Sub
End Sub

Private Sub cmdOK_Click()
On Error GoTo cmdOk_Click_Err

Forms![frmDataDrive].Visible = False

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria

cmdOk_Click_Exit:
Exit Sub
cmdOk_Click_Err:

Resume cmdOk_Click_Exit
End Sub


Thanks for any suggestions


.
 
Never mind I figured it out. Could you tell me if this is
going to cause me problems later?

DoCmd.TransferText acImportDelim, "", "tblPeopleData",
fDrive1 & "://tblPeopleData.txt", True, ""

thanks for any input
-----Original Message-----
Are you keeping frmDataDrive open after the user enters the drive letter?
Instead of closing that form, assuming that you're using a command button to
let the user indicate that the drive letter has been entered, just make the
form invisible. Then your posted code can read the value from that form.
Your posted code then needs an additional step after reading that value so
that the second form is closed:

DoCmd.Close acForm, "frmDataDrive"

--

Ken Snell
<MS ACCESS MVP>

T said:
Can someone help me on this? I have a form with a
button. When someone presses the bitton another form
opens up which asks the person to select a drive they want
to use to download a txt file. After they insert a drive
letter and select ok then it should pass that vai\riable
to the main form for it to continue downloading. here is
my cod from the main then the drive form.

Private Sub drive_Click()
On Error GoTo Err_drive_Click

DoCmd.OpenForm "frmDataDrive", , , , , acDialog
Dim fDrive1 As Variant
fDrive1 = Forms!frmDataDrive!txtDrive

DoCmd.Hourglass True
DoCmd.TransferText
acImportDelim, "", "tblPeopleData", "fdrive1://tblPeopleDat
a.txt", True, ""
DoCmd.Hourglass False
Exit_drive_Click:
Exit Sub
Err_drive_Click:
MsgBox Error$
Exit Sub
End Sub

Private Sub cmdOK_Click()
On Error GoTo cmdOk_Click_Err

Forms![frmDataDrive].Visible = False

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria

cmdOk_Click_Exit:
Exit Sub
cmdOk_Click_Err:

Resume cmdOk_Click_Exit
End Sub


Thanks for any suggestions


.
 
I would never try to predict whether a code will / won't cause problems
later, but what you've posted is an appropriate use of VBA code snyntax.

--

Ken Snell
<MS ACCESS MVP>

T said:
Never mind I figured it out. Could you tell me if this is
going to cause me problems later?

DoCmd.TransferText acImportDelim, "", "tblPeopleData",
fDrive1 & "://tblPeopleData.txt", True, ""

thanks for any input
-----Original Message-----
Are you keeping frmDataDrive open after the user enters the drive letter?
Instead of closing that form, assuming that you're using a command button to
let the user indicate that the drive letter has been entered, just make the
form invisible. Then your posted code can read the value from that form.
Your posted code then needs an additional step after reading that value so
that the second form is closed:

DoCmd.Close acForm, "frmDataDrive"

--

Ken Snell
<MS ACCESS MVP>

T said:
Can someone help me on this? I have a form with a
button. When someone presses the bitton another form
opens up which asks the person to select a drive they want
to use to download a txt file. After they insert a drive
letter and select ok then it should pass that vai\riable
to the main form for it to continue downloading. here is
my cod from the main then the drive form.

Private Sub drive_Click()
On Error GoTo Err_drive_Click

DoCmd.OpenForm "frmDataDrive", , , , , acDialog
Dim fDrive1 As Variant
fDrive1 = Forms!frmDataDrive!txtDrive

DoCmd.Hourglass True
DoCmd.TransferText
acImportDelim, "", "tblPeopleData", "fdrive1://tblPeopleDat
a.txt", True, ""
DoCmd.Hourglass False
Exit_drive_Click:
Exit Sub
Err_drive_Click:
MsgBox Error$
Exit Sub
End Sub

Private Sub cmdOK_Click()
On Error GoTo cmdOk_Click_Err

Forms![frmDataDrive].Visible = False

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria

cmdOk_Click_Exit:
Exit Sub
cmdOk_Click_Err:

Resume cmdOk_Click_Exit
End Sub


Thanks for any suggestions


.
 
Ken,

He indicated that the second form was opened in dialog mode. If I'm
interpreting you correctly, that means that by setting that forms visible
property to false, Access assumes the form has been closed, and will resume
processing of the code in the original forms code module. Is that correct?
If so, do you know what versions of Access this technique works for?

Thanks

Dale

Ken Snell said:
Are you keeping frmDataDrive open after the user enters the drive letter?
Instead of closing that form, assuming that you're using a command button to
let the user indicate that the drive letter has been entered, just make the
form invisible. Then your posted code can read the value from that form.
Your posted code then needs an additional step after reading that value so
that the second form is closed:

DoCmd.Close acForm, "frmDataDrive"

--

Ken Snell
<MS ACCESS MVP>

T said:
Can someone help me on this? I have a form with a
button. When someone presses the bitton another form
opens up which asks the person to select a drive they want
to use to download a txt file. After they insert a drive
letter and select ok then it should pass that vai\riable
to the main form for it to continue downloading. here is
my cod from the main then the drive form.

Private Sub drive_Click()
On Error GoTo Err_drive_Click

DoCmd.OpenForm "frmDataDrive", , , , , acDialog
Dim fDrive1 As Variant
fDrive1 = Forms!frmDataDrive!txtDrive

DoCmd.Hourglass True
DoCmd.TransferText
acImportDelim, "", "tblPeopleData", "fdrive1://tblPeopleDat
a.txt", True, ""
DoCmd.Hourglass False
Exit_drive_Click:
Exit Sub
Err_drive_Click:
MsgBox Error$
Exit Sub
End Sub

Private Sub cmdOK_Click()
On Error GoTo cmdOk_Click_Err

Forms![frmDataDrive].Visible = False

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria

cmdOk_Click_Exit:
Exit Sub
cmdOk_Click_Err:

Resume cmdOk_Click_Exit
End Sub


Thanks for any suggestions
 
When a code step opens a form in dialog mode, that code stops processing
until the opened form is either closed or made invisible. To my knowledge,
this works in all versions of ACCESS. I use this technique all the time.

--

Ken Snell
<MS ACCESS MVP>

Dale Fye said:
Ken,

He indicated that the second form was opened in dialog mode. If I'm
interpreting you correctly, that means that by setting that forms visible
property to false, Access assumes the form has been closed, and will resume
processing of the code in the original forms code module. Is that correct?
If so, do you know what versions of Access this technique works for?

Thanks

Dale

Ken Snell said:
Are you keeping frmDataDrive open after the user enters the drive letter?
Instead of closing that form, assuming that you're using a command
button
to
let the user indicate that the drive letter has been entered, just make the
form invisible. Then your posted code can read the value from that form.
Your posted code then needs an additional step after reading that value so
that the second form is closed:

DoCmd.Close acForm, "frmDataDrive"

--

Ken Snell
<MS ACCESS MVP>

T said:
Can someone help me on this? I have a form with a
button. When someone presses the bitton another form
opens up which asks the person to select a drive they want
to use to download a txt file. After they insert a drive
letter and select ok then it should pass that vai\riable
to the main form for it to continue downloading. here is
my cod from the main then the drive form.

Private Sub drive_Click()
On Error GoTo Err_drive_Click

DoCmd.OpenForm "frmDataDrive", , , , , acDialog
Dim fDrive1 As Variant
fDrive1 = Forms!frmDataDrive!txtDrive

DoCmd.Hourglass True
DoCmd.TransferText
acImportDelim, "", "tblPeopleData", "fdrive1://tblPeopleDat
a.txt", True, ""
DoCmd.Hourglass False
Exit_drive_Click:
Exit Sub
Err_drive_Click:
MsgBox Error$
Exit Sub
End Sub

Private Sub cmdOK_Click()
On Error GoTo cmdOk_Click_Err

Forms![frmDataDrive].Visible = False

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria

cmdOk_Click_Exit:
Exit Sub
cmdOk_Click_Err:

Resume cmdOk_Click_Exit
End Sub


Thanks for any suggestions
 
Back
Top