Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Latest Flex question

Status
Not open for further replies.

vbajock

Programmer
Jun 8, 2001
1,921
US
Inventory transaction screen,2401. In the macform.initform event, I want to check to see if the user has certain files on his local drive, and if he doesn't, not allow him to enter Inventory trans. The usual VBA unload commands or calling the macform.close event, of course do not work.
 
vbajock,
Are you trying to insure that some local files are there for other flex that is running? If the reason to do this is to simply control access to the transactions then I would simply remove this ability through the visual menu builder.

If you have need for these files for some other flex or something then I would put a piece in that copies the files to the proper location on loading the form.

The only way that I have ever found that you can close the form is to put flex on the TrxType_LoseFocus event that if the files are not there then pop a msgbox that informs the user and does not allow the TrxType to loose focus. Have the user close the form themselves.

Andy

Andy Baldwin
 
Andy, on the local file thing, I wrote a flex program that adds the ability to add the reason codes from SYDEFIL to the IMINVTRX file when an inventory transaction is done. I don't want the user to enter inventory transactions unless he has my program installed on his local drive. In the normal world, I would simply check for the file and then use VBA to close the window after displaying a message to contact the SA to get the program installed. In the Macola world, even if the guy doesn't have the program he can still enter transactions because I can't get the window to close. I think I am going to try experimenting with the hwnd property and use Windows API calls to see if I can get the stupid thing to close.
 
I can tell you now that the hwnd property does not work either. This is especially annoying on user forms.

Does the program that you wrote require additional controls that are not installed by Macola and Flex. In other words.

IF exist c:\myprogram.exe = false then
copy m:\myprogram.exe c:\myprogram.exe
end if

This way the program is copied to the specified directory so that if the user does not have it it will be copied and ready for use. This should work unless you have used controls that are not available on the local machine.

Andy

Andy Baldwin
 
Whether or not to install the program for a given user is a descision the customer wants to reserve for himself. I think I am just going tell them they will have allow an automatic download and they will have to just use Macola security to deal with it. The reason I will give for this is that Flex is not good.
 
Hello All,

I have a nice and ugly solution for you, but it seems to handle your problem.

' Begin Inventory Transaction Flex Code
Private Const cSomeFileName As String = "C:\somefile.exe"
Private m_bProgramNotInstalled As Boolean

Private Sub DocDate_GotFocus()
If m_bProgramNotInstalled = True Then
SendKeys "{ESC}"
End If
End Sub

Private Sub TrxType_GotFocus()
If m_bProgramNotInstalled = True Then
SendKeys "{ESC}"
Else
If FileExists(cSomeFileName) = True Then
m_bProgramNotInstalled = False
Else
m_bProgramNotInstalled = True
MsgBox "Program not installed, please call SA", vbInformation
DocDate.SetFocus
End If
End If
End Sub

Private Function FileExists(ByRef FileName As String) As Boolean
On Error GoTo ErrHandler

If Len(Dir(FileName)) > 0 Then
FileExists = True
Else
FileExists = False
End If

Exit Function
ErrHandler:
FileExists = False
End Function
' End Inventory Transaction Flex Code.

I hope this helps you out. As a side note I'm glad to have found this forum, I've thought about trying to establish something like this for some time. I will definitely use it. Oh and I hope things are going well for you Andy (that is if you see this).

Scott Travis
 
Scott, the problem was how to close a Macola window via VBA code. It does not seem to be possible with Flex of standard VBA commands. If your code frag solves that problem, I must have missed it.
 
I think you would have to send 2 ESC keys. One to exit off the record and one to exit out of the form.

Will try this later and see how it works.

Andy

Andy Baldwin
 
My code does solve the specific problem presented. However, under most circumstances you can close a Macola screen on startup simply by putting two lines of code in the GotFocus event of the first control in the tab order for a Macola screen. The two lines of code are presented below.

' Begin Close Form Code
SendKeys "{ESC}"
SendKeys "{ESC}"
' End Close Form Code

Now in the case that you presented you wanted a Message Box to display. If the message box pops up before the sendkeys command for whatever reason the SendKeys command no longer works. Therefore, the code in my earlier post presents a purely Flex based work around. You could also Shell out to a custom app that performs the SendKeys operation for you. If you are interested I have a VB app that does this that accepts command line parameters for the key command to send, and how much time to wait before sending the command.

Please paste the code in the post above in to the Inventory Transaction Screens VBA Editor, save the code, close the screenset, open it, and watch it do it's thing. If you wish to get in to the code again you will need to hit the Ctrl+Pause|Break key combo when the message box appears.

Hope this helps to clarify,
Scott Travis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top