David-
What kind of control is ResultsTxt and ResultsDec? Do the names of the controls match the field names, or did you give them some other name? Also, if the Numeric field does not have a default value, you'll get invalid use of Null when you move to a new record. You can fix it like this:
Private Sub Form_Current()
' If on a new record,
If Me.NewRecord Then
' Make sure Numeric has a value
Me.Numeric = True
End If
If Me.Numeric Then
Me.ResultsTxt.Locked = True
Me.ResultsDec.Locked = False
Else
Me.ResultsTxt.Locked = False
Me.ResultsDec.Locked = True
End If
End Sub
You should probably also have code in AfterUpdate of the Numeric field if the user can change that.
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
(Paris, France)
On Dec 13, 2016, at 4:36 AM, david.pratt@outlook.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
Another unsuccessful hour. This VBA code is killing me but I am learning.
The procedure under form current is not working. A couple of times I received an error saying invalid use of Null; then the last time I got a message saying something about not recognizing the Locked property. When I try to use the "help" system to type the statement, the "locked" property is not a choice for the control.
The other procedure works fine.
Thank you for all your help.
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
David-
I recommend you use a Continuous form - you'll have much more control over the layout.
These both go in the subform module:
Private Sub Form_Current()
If Me.Numeric Then
Me.ResultsTxt.Locked = True
Me.ResultsDec.Locked = False
Else
Me.ResultsTxt.Locked = False
Me.ResultsDec.Locked = True
End If
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Numeric Then
If IsNull(Me.ResultsDec) Then
MsgBox "You must enter a result in the Decimal field."
Cancel = True
End If
Else
If Len(Me.ResultsTxt & "") = 0 Then
MsgBox "You must enter a result in the Text field."
Cancel = True
End If
End IF
End Sub
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
(Paris, France)
On Dec 11, 2016, at 2:10 PM, David Pratt david.pratt@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
In my Parameters table I will add two descriptive fields
- One field is a Yes/No named Numeric with default YES
- One field is named Comparator. It needs to be a List with choices of "=, <, > "
The input form will contain the Comparator field and the user will have to select the comparator for each result, but the default is "=" so input is easy. I probably will not even include a Tab Stop on that field since it is seldom that the Comparator is anything other than "=". Any reports will need to concatenate the Comparator field and Result field, but hide the comparator if the comparator is "=", and also hide the Comparator if the Result is a text. I will have to delay thinking about how to do this until later.
For now I need more guidance on the input form (datasheet based on tblServiceReportDetails). If the Parameter in the current record has Numeric = Yes, I want to force the user to input into the ResultsDec field, and if the Parameter in the current record has Numeric = No, I want to force the user to input into the ResultsTxt field. Can you give more details on how to code this and on what Event?
Thank you,
David
__._,_.___
Posted by: John Viescas <johnv@msn.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (14) |
Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.
.
__,_._,___
Tidak ada komentar:
Posting Komentar