kgcrowther
Registered User.
- Local time
- Today, 16:11
- Joined
- Jun 1, 2001
- Messages
- 52
I don't know much about VB and I think that's why I'm having the following problem. I've set a variable as public that can be set from the main switchboard. I called it ActProj (Active Project). This is what I wrote in a module called 'SetVars'
Option Explicit
Public ActProj As String
After you set the Active project on the switchboard I want to use this variable to filter all forms and reports. When adding information I want this number to automatically fill in. I've tried everything, but nothing works. I've gotten all sorts of errors from run-time errors to "this object cannot be found" type of errors. I think I might be referencing the variable incorrectly. These are some of the things that I've tried.
I've tried the following in the OnOpen of varios forms:
Private Sub Form_Open(Cancel As Integer)
Set ProjectNum.Value = ActProj
End Sub
Private Sub Form_Open(Cancel As Integer)
Set ProjectNum = ActProj
End Sub
Private Sub Form_Open(Cancel As Integer)
ProjectNum.Caption = ActProj
End Sub
...And many other variations.
OnClick from the openform control I've tried:
Private Sub openform_Click()
Dim openThis As String
Dim filterThis As String
openThis = "Project Assets"
filterThis = "[ProjectNum]=" & "'" & ActProj & "'"
DoCmd.openform openThis, , , filterThis
End Sub
...And variations of this.
I've tried some other thing, but nothing has worked. I think I might be refering to the public variable incorrectly. Does anyone know what I'm doing wrong. I feel like I'm just wasting time and I don't even know where to go to find my answer. Any ideas would be helpful.
Thanks,
Kenneth
Option Explicit
Public ActProj As String
After you set the Active project on the switchboard I want to use this variable to filter all forms and reports. When adding information I want this number to automatically fill in. I've tried everything, but nothing works. I've gotten all sorts of errors from run-time errors to "this object cannot be found" type of errors. I think I might be referencing the variable incorrectly. These are some of the things that I've tried.
I've tried the following in the OnOpen of varios forms:
Private Sub Form_Open(Cancel As Integer)
Set ProjectNum.Value = ActProj
End Sub
Private Sub Form_Open(Cancel As Integer)
Set ProjectNum = ActProj
End Sub
Private Sub Form_Open(Cancel As Integer)
ProjectNum.Caption = ActProj
End Sub
...And many other variations.
OnClick from the openform control I've tried:
Private Sub openform_Click()
Dim openThis As String
Dim filterThis As String
openThis = "Project Assets"
filterThis = "[ProjectNum]=" & "'" & ActProj & "'"
DoCmd.openform openThis, , , filterThis
End Sub
...And variations of this.
I've tried some other thing, but nothing has worked. I think I might be refering to the public variable incorrectly. Does anyone know what I'm doing wrong. I feel like I'm just wasting time and I don't even know where to go to find my answer. Any ideas would be helpful.
Thanks,
Kenneth