Custom Input Box (1 Viewer)

ascaife

Registered User.
Local time
Today, 17:03
Joined
Nov 10, 2008
Messages
50
I have an existing procedure using transfertext that utilises an input box to prompt for the filename to save to. I would really love to customise the input box to fit in with the overall look of the rest of the application.

Can anyone point me in the direction of some instructions to do this. I'm a novice so as much detail on the code as possible would be great.

Cheers,

Andy
 

namliam

The Mailman - AWF VIP
Local time
Today, 09:03
Joined
Aug 11, 2003
Messages
11,695
Have a search for "file dialog" see if that is what you want...
Alternatively you can design a form you popup before running the query, and draw the information of the form...

Good luck, let me know if you run into problems.
 

ascaife

Registered User.
Local time
Today, 17:03
Joined
Nov 10, 2008
Messages
50
Apparently the file dialog won't work in Access Runtime so that won't be any good.

I'm okay with designing a custom form but not sure how to pass the entered text into the procedure.

I'm using a custom message box which works great, but I had some help putting that in and it comes up using the Dialog.Box instead of MsgBox.

If you could give me some advice as to how the vba would be inserted for the input box that would be great.

My code is as follows:

Private Sub Command4_Click()
DoCmd.TransferText acExportFixed, "VDU", "qryVDU", "C:\Import\VDU.txt", No
DoCmd.CancelEvent
Dim strFilename As String
strFilename = InputBox("Enter VDU File Name:", "FHM")
If Len(strFilename) > 0 Then
strFilename = "C:\Import\" & strFilename
Dim vResponse As VbMsgBoxResult
If Dir(strFilename) = "" Then
Name "C:\Import\VDU.txt" As strFilename
Dialog.Box Prompt:="You have successfully created the VDU file in C:\Import", _
Buttons:=(vbOKOnly + vbInformation), _
Title:="Well Done", _
ButtonDelay:=0

Else
vResponse = Dialog.Box("That file already exists. Would you like to overwrite it?", vbQuestion + vbYesNo, "Overwrite File?")
If vResponse = vbYes Then
Kill strFilename
Name "C:\Import\VDU.txt" As strFilename
Dialog.Box Prompt:="You have successfully created the VDU file in C:\Import", _
Buttons:=(vbOKOnly + vbInformation), _
Title:="Well Done", _
ButtonDelay:=0
End If
End If
End If
End Sub
 
Last edited:

namliam

The Mailman - AWF VIP
Local time
Today, 09:03
Joined
Aug 11, 2003
Messages
11,695
Forms("formname").Control("yourControl") will fetch anything of any open form.... assuming you know what formname and what control it is..

Re: Private Sub Command4_Click()

Command4 ?? PLEASE PLEASE PLEASE do not leave the default control names, this makes an application look bad AND makes for a maintenance mess as in 3 months time you will not know what is Command4 for a button.
If instead you call it cmdImportFile, you instantly by its name know what its purpose is without looking at the button on the form or at the code.
 

ascaife

Registered User.
Local time
Today, 17:03
Joined
Nov 10, 2008
Messages
50
I've just added a filename box to my form, then instead of using the line with inputbox, I replaced with [Forms]![frmOutputToFile]![VDUFilename]

Re the Command4 naming, I know it's bad habit but I was just mucking around with the functionality to begin with, I should name the command before I even do any testing though - the command button is now called cmdExportVDU

Thanks for all your help, greatly appreciated.
 

Users who are viewing this thread

Top Bottom