dbTalk Databases Forums  

FM Newbie....Help with Conversion of Controls

comp.databases.filemaker comp.databases.filemaker


Discuss FM Newbie....Help with Conversion of Controls in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
MOC835
 
Posts: n/a

Default FM Newbie....Help with Conversion of Controls - 01-28-2007 , 02:45 PM






I developed a database in MS Access to track and control the issuance
of computers to a mobile workforce.

My DB has the following tables/attributes

TblEmployees
EmployeeID
FirstName
LastName

TblComputers
ComputerID
ModelNum
SerialNum

TblAssignments
AssignID
ComputerID
EmployeeID
IssueDate
ReturnDate

My VBA Code in Access performs the following control:
(1) Verifies that an employee does not have a computer already
assigned to him.
(2) The same computer is not assigned to another person. (in other
words the computer is checked out under another employee, but the
'ReturnDate' Field is empty (null).

Here is the Access VBA Code I used. Any help on getting this
function to work in Filemaker would be appreciated.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strWhere As String
Dim strMsg As String
Dim varResult As Variant

If IsNull(Me.ReturnDate) And Not (IsNull(Me.EmployeeID) Or
IsNull(Me.ComputerID)) Then
'Block 2 assignments to same employee.
strWhere = "(ReturnDate Is Null) AND (EmployeeID = " & _
Me.EmployeeID & ") AND (AssignID <> " & Me.AssignID & ")"
varResult = DLookup("ComputerID", "Assign", strWhere)
If Not IsNull(varResult) Then
Cancel = True
strMsg = strMsg & "Employee already has computer " &
varResult &
"." & vbCrLf
End If

'Block assigning computer to 2 employees.
strWhere = "(ReturnDate Is Null) AND (ComputerID = " & _
Me.ComputerID & ") AND (AssignID <> " & Me.AssignID & ")"
varResult = DLookup("EmployeeID", "Assign", strWhere)
If Not IsNull(varResult) Then
Cancel = True
strMsg = strMsg & "Computer already assigned to employee "
&
varResult & "." & vbCrLf
End If
End If

'Display message.
If Cancel Then
strMsg = strMsg & vbCrLf & "Correct the entry, or press <Esc>
to
undo."
MsgBox strMsg, vbExplanation, "Invalid entry"
End If
End Sub


Again....since I am new to Filemaker....I would appreciate any
help...as detailed as possible!
Thanks


Reply With Quote
  #2  
Old   
Ursus
 
Posts: n/a

Default Re: FM Newbie....Help with Conversion of Controls - 01-28-2007 , 03:05 PM






Filemaker pro only has a very limited activex object. This simply can not be
done with any external scripting. However filemaker comes with its own set
of script steps and calculation functions. As far as I see there is no
reason why you can't make this work inside filemaker.

The if IsNull function is if IsEmpty() in filemaker. You don't need to
declare any variables as such. You can either create them as a calculation.
Or if you need variables (FMP 8) you just create them when needed. It is
perfectly possible to have the script exit with a custom exit-code.

I don't have the time now to go through the steps needed, but my tip for you
is to dissect as many solutions as you can find and start trying yourself.
Don't forget the help-file, there's a lot of help there.

Ursus

Quote:
My VBA Code in Access performs the following control:
(1) Verifies that an employee does not have a computer already
assigned to him.
(2) The same computer is not assigned to another person. (in other
words the computer is checked out under another employee, but the
'ReturnDate' Field is empty (null).

Here is the Access VBA Code I used. Any help on getting this
function to work in Filemaker would be appreciated.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strWhere As String
Dim strMsg As String
Dim varResult As Variant

If IsNull(Me.ReturnDate) And Not (IsNull(Me.EmployeeID) Or
IsNull(Me.ComputerID)) Then
'Block 2 assignments to same employee.
strWhere = "(ReturnDate Is Null) AND (EmployeeID = " & _
Me.EmployeeID & ") AND (AssignID <> " & Me.AssignID & ")"
varResult = DLookup("ComputerID", "Assign", strWhere)
If Not IsNull(varResult) Then
Cancel = True
strMsg = strMsg & "Employee already has computer " &
varResult &
"." & vbCrLf
End If

'Block assigning computer to 2 employees.
strWhere = "(ReturnDate Is Null) AND (ComputerID = " & _
Me.ComputerID & ") AND (AssignID <> " & Me.AssignID & ")"
varResult = DLookup("EmployeeID", "Assign", strWhere)
If Not IsNull(varResult) Then
Cancel = True
strMsg = strMsg & "Computer already assigned to employee "
&
varResult & "." & vbCrLf
End If
End If

'Display message.
If Cancel Then
strMsg = strMsg & vbCrLf & "Correct the entry, or press <Esc
to
undo."
MsgBox strMsg, vbExplanation, "Invalid entry"
End If
End Sub


Again....since I am new to Filemaker....I would appreciate any
help...as detailed as possible!
Thanks




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.