conversions

  • Thread starter Thread starter misschanda via AccessMonster.com
  • Start date Start date
M

misschanda via AccessMonster.com

Hello,
I have a mathematical issue.
I have a table that has size in (mm). on the same table there is also a field
for size in inches. to convert the mm to in i inserted in field two: size(in)
=[size(mm)]*0.0394.

some of the records however has size as a dimension... for example product
737 has a size of 0.67X0.89mm when this converted to inches and Error is
displayed in the text field. Is there a way to program so that it knows that
0.67 and 0.89 are both measurements???

Thanks,
LA
 
LA, this function will convert millimeters to inches in a single number
format or the 99X99 format.
The output will be the same format as the input, converted to inches.

Function fcnConvMMtoIN(arg As String) As String
Dim D1 As Variant
Dim D2 As Variant
Dim pos As Long
Dim pos2 As Long
pos = InStr(arg, "X")
pos2 = InStr(pos + 1, arg, "X")
If pos = 1 Or pos = Len(arg) Or pos2 > 0 Then
MsgBox "Malformed dimension " & arg
fcnConvMMtoIN = "ERROR"
Exit Function
End If
If pos > 0 Then
D1 = Val(arg) * 0.0394
D2 = Val(Mid(arg, pos + 1)) * 0.0394
fcnConvMMtoIN = D1 & "X" & D2
Else
fcnConvMMtoIN = (arg * 0.0394)
End If
End Function

UpRider
 
thanks, is this function entered in field2 under the event after update???
la
LA, this function will convert millimeters to inches in a single number
format or the 99X99 format.
The output will be the same format as the input, converted to inches.

Function fcnConvMMtoIN(arg As String) As String
Dim D1 As Variant
Dim D2 As Variant
Dim pos As Long
Dim pos2 As Long
pos = InStr(arg, "X")
pos2 = InStr(pos + 1, arg, "X")
If pos = 1 Or pos = Len(arg) Or pos2 > 0 Then
MsgBox "Malformed dimension " & arg
fcnConvMMtoIN = "ERROR"
Exit Function
End If
If pos > 0 Then
D1 = Val(arg) * 0.0394
D2 = Val(Mid(arg, pos + 1)) * 0.0394
fcnConvMMtoIN = D1 & "X" & D2
Else
fcnConvMMtoIN = (arg * 0.0394)
End If
End Function

UpRider
Hello,
I have a mathematical issue.
[quoted text clipped - 12 lines]
Thanks,
LA
 
LA, add these events to your form:

Private Sub Form_Current()
If IsNull(Field1) Then Exit Sub
Field2 = fcnConvMMtoIN(Field1)
Me.Refresh
End Sub

Private Sub Field1_AfterUpdate()
If IsNull(Field1) Then Exit Sub
Field2 = fcnConvMMtoIN(Field1)
End Sub

If you are typing in new dimensions into field1 then you need the
after_update above.
The form_current will do the conversion while scrolling thru the records.

In any case, set the locked property of field2 to true. You don't want to be
able to type anything into field2.

UpRider

misschanda via AccessMonster.com said:
thanks, is this function entered in field2 under the event after update???
la
LA, this function will convert millimeters to inches in a single number
format or the 99X99 format.
The output will be the same format as the input, converted to inches.

Function fcnConvMMtoIN(arg As String) As String
Dim D1 As Variant
Dim D2 As Variant
Dim pos As Long
Dim pos2 As Long
pos = InStr(arg, "X")
pos2 = InStr(pos + 1, arg, "X")
If pos = 1 Or pos = Len(arg) Or pos2 > 0 Then
MsgBox "Malformed dimension " & arg
fcnConvMMtoIN = "ERROR"
Exit Function
End If
If pos > 0 Then
D1 = Val(arg) * 0.0394
D2 = Val(Mid(arg, pos + 1)) * 0.0394
fcnConvMMtoIN = D1 & "X" & D2
Else
fcnConvMMtoIN = (arg * 0.0394)
End If
End Function

UpRider
Hello,
I have a mathematical issue.
[quoted text clipped - 12 lines]
Thanks,
LA
 
Back
Top