Auto populate memo fields

  • Thread starter Thread starter Jsun via AccessMonster.com
  • Start date Start date
J

Jsun via AccessMonster.com

I have an issue where I am trying to auto populate two different memo
fields based on my selection using a combo box. If I select -1 then it
would go into memo field NFMinusComment, and if it is +1 then it would go
into NFPlusComment. Zero is the default and would not need anything
entered. When I currently make my selection it is populating into both
fields when I make other field selections. Here is what I currently have.

Dim MX1(3) As Variant
Dim MX2(3) As Variant
Dim MX3(3) As Variant
Dim M04(3) As Variant
Dim M05(3) As Variant

Const A1 As Integer = 1
Private Sub Minus()
NFMinusComment = MX1(0) & vbCrLf & MX2(0) & vbCrLf & MX3(0) & vbCrLf & M05
(0)
End Sub
Private Sub Plus()
NFPlusComment = PX1(1) & vbCrLf & PX2(1) & vbCrLf & PX3(1) & vbCrLf & P04(1)
& vbCrLf & P05(1)
End Sub

Private Sub GE05_UsePropOpen_BeforeUpdate(Cancel As Integer)

If GE05_UsePropOpen = -2 Or -1 Then
If A1 = 1 Then
MX1(0) = "GE-05 Used proper opening: "
Call Minus
NFMinusComment.Visible = True
NFPlusComment.Visible = True
PX1(1) = Null
Call Plus
End If
End If

If GE05_UsePropOpen = "0" Then
NFMinusComment.Visible = True
NFPlusComment.Visible = True
MX1(0) = " "
Call Minus
PX1(1) = " "
Call Plus
End If

If GE05_UsePropOpen = 1 Then
If A1 = 1 Then
PX1(1) = "GE-05 Used proper opening: "
Call Plus
NFMinusComment.Visible = True
NFPlusComment.Visible = True
MX1(0) = Null
Call Minus
End If
End If

End Sub

Any help would be much appreciated. Thank you
 
Comments inline......

Jsun via AccessMonster.com said:
I have an issue where I am trying to auto populate two different memo
fields based on my selection using a combo box. If I select -1 then it
would go into memo field NFMinusComment, and if it is +1 then it would go
into NFPlusComment. Zero is the default and would not need anything
entered. When I currently make my selection it is populating into both
fields when I make other field selections. Here is what I currently have.

Dim MX1(3) As Variant
Dim MX2(3) As Variant
Dim MX3(3) As Variant
Dim M04(3) As Variant
Dim M05(3) As Variant

Const A1 As Integer = 1
Private Sub Minus()
NFMinusComment = MX1(0) & vbCrLf & MX2(0) & vbCrLf & MX3(0) & vbCrLf & M05
(0)
End Sub
Private Sub Plus()
NFPlusComment = PX1(1) & vbCrLf & PX2(1) & vbCrLf & PX3(1) & vbCrLf & P04(1)
& vbCrLf & P05(1)
End Sub

Private Sub GE05_UsePropOpen_BeforeUpdate(Cancel As Integer)

If GE05_UsePropOpen = -2 Or -1 Then

The second condition (after the OR) is -1 (True). So the line can be written
as:

If GE05_UsePropOpen = -2 Or TRUE Then....

No matter what (GE05_UsePropOpen = -2) evaluates to, because of the -1
(True), the conditional test *always* is TRUE. It should be written as:

If GE05_UsePropOpen = -2 Or GE05_UsePropOpen = -1 Then

If A1 = 1 Then

This line is useless because you defined A1 as a constant = 1.
A1 = 1 is *always* True and will always execute.
MX1(0) = "GE-05 Used proper opening: "
Call Minus
NFMinusComment.Visible = True
NFPlusComment.Visible = True
PX1(1) = Null
Call Plus
End If
End If

If GE05_UsePropOpen = "0" Then

Do you want a number zero or a text string that is zero? I think you should
delete the quotes.
NFMinusComment.Visible = True
NFPlusComment.Visible = True
MX1(0) = " "
Call Minus
PX1(1) = " "
Call Plus
End If

If GE05_UsePropOpen = 1 Then
If A1 = 1 Then

Again, this condition is always True, so it can be deleted.
 
Thank you for your help. I found that trying to adding different field into
the memo was causing problems. Seemed to be overwriting when I made the
next selection. I ended up going about it a different way.

Thanks again,
 
Back
Top