Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Inbox issues

Geek News

Inbox issues
kharpe 12/5/2008 7:09:01 PM
I have a form with a button used to open a second form. The SQL code behind
the button opens an input box for user input of an "FCSI Number". When the
user enters a valid FCSI number, the second form opens correctly. There are
two instances during which I recieve an error. The first is if the user
cancels the input box, and the second is if no value is entered for the "FCSI
number"

Private Sub AddRemove_Click()
On Error GoTo Err_ADDRemove_Click

Dim DocName As String
Dim StCriteria As String

Dim stMsg As String
Dim stInput As String

DocName = "WPAddRemove"

stMsg = "Enter FCSI number"
'Prompt for input
stInput = InputBox(stMsg)
StCriteria = BuildCriteria("FCSI_ID", dbInteger, stInput)
StCriteria = StCriteria & "And " & "[Vessel_ID]=" & Me![Vessel_ID]
DoCmd.OpenForm DocName, , , StCriteria
Forms!WPAddRemove!WP_ID.DefaultValue = "" & Me![WP_Key] & ""

Exit_ADDRemove_Click:
Set rs = Nothing
Set qdf = Nothing
Set db = Nothing
Exit Sub

Err_ADDRemove_Click:
MsgBox Err.Description
Resume Exit_ADDRemove_Click

End Sub

The above is the code for the sub. If anyone can help me with capturing the
two errors it would be apreciated.

Re: Inbox issues
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> 12/5/2008 7:58:02 PM
It's the same check for both errors:

Private Sub AddRemove_Click()
On Error GoTo Err_ADDRemove_Click

Dim DocName As String
Dim StCriteria As String

Dim stMsg As String
Dim stInput As String

DocName = "WPAddRemove"

stMsg = "Enter FCSI number"
'Prompt for input
stInput = InputBox(stMsg)
If Len(stInput) = 0 Then
MsgBox "You must spupply an FCSI number."
Else
StCriteria = BuildCriteria("FCSI_ID", dbInteger, stInput)
StCriteria = StCriteria & "And " & "[Vessel_ID]=" & Me![Vessel_ID]
DoCmd.OpenForm DocName, , , StCriteria
Forms!WPAddRemove!WP_ID.DefaultValue = "" & Me![WP_Key] & ""
End If

Exit_ADDRemove_Click:
Set rs = Nothing
Set qdf = Nothing
Set db = Nothing
Exit Sub

Err_ADDRemove_Click:
MsgBox Err.Description
Resume Exit_ADDRemove_Click

End Sub




--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"kharpe" <kharpe[ at ]discussions.microsoft.com> wrote in message
news:40189CC2-4875-4723-87D9-4CBFAD305CF0[ at ]microsoft.com...
[Quoted Text]
>I have a form with a button used to open a second form. The SQL code behind
> the button opens an input box for user input of an "FCSI Number". When the
> user enters a valid FCSI number, the second form opens correctly. There
> are
> two instances during which I recieve an error. The first is if the user
> cancels the input box, and the second is if no value is entered for the
> "FCSI
> number"
>
> The above is the code for the sub. If anyone can help me with capturing
> the
> two errors it would be apreciated.
>


Re: Inbox issues
kharpe 12/5/2008 8:19:01 PM
That helps. I want the input box to close when the cancel button is pressed,
but to re-open if no Value is entered, but the OK button is pressed. Is there
a method that I can differentiate between which oft the two buttons is
pressed on the input box?

"Douglas J. Steele" wrote:

[Quoted Text]
> It's the same check for both errors:
>
> Private Sub AddRemove_Click()
> On Error GoTo Err_ADDRemove_Click
>
> Dim DocName As String
> Dim StCriteria As String
>
> Dim stMsg As String
> Dim stInput As String
>
> DocName = "WPAddRemove"
>
> stMsg = "Enter FCSI number"
> 'Prompt for input
> stInput = InputBox(stMsg)
> If Len(stInput) = 0 Then
> MsgBox "You must spupply an FCSI number."
> Else
> StCriteria = BuildCriteria("FCSI_ID", dbInteger, stInput)
> StCriteria = StCriteria & "And " & "[Vessel_ID]=" & Me![Vessel_ID]
> DoCmd.OpenForm DocName, , , StCriteria
> Forms!WPAddRemove!WP_ID.DefaultValue = "" & Me![WP_Key] & ""
> End If
>
> Exit_ADDRemove_Click:
> Set rs = Nothing
> Set qdf = Nothing
> Set db = Nothing
> Exit Sub
>
> Err_ADDRemove_Click:
> MsgBox Err.Description
> Resume Exit_ADDRemove_Click
>
> End Sub
>
>
>
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "kharpe" <kharpe[ at ]discussions.microsoft.com> wrote in message
> news:40189CC2-4875-4723-87D9-4CBFAD305CF0[ at ]microsoft.com...
> >I have a form with a button used to open a second form. The SQL code behind
> > the button opens an input box for user input of an "FCSI Number". When the
> > user enters a valid FCSI number, the second form opens correctly. There
> > are
> > two instances during which I recieve an error. The first is if the user
> > cancels the input box, and the second is if no value is entered for the
> > "FCSI
> > number"
> >
> > The above is the code for the sub. If anyone can help me with capturing
> > the
> > two errors it would be apreciated.
> >
>
>
>
Re: Inbox issues
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> 12/6/2008 1:21:17 PM
There's no way that I'm aware of to distinguish between the two actions.

What you can do is set a default value of 0. If they click OK, the input box
will return 0, if they click cancel, the input box will return a zero-length
string.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"kharpe" <kharpe[ at ]discussions.microsoft.com> wrote in message
news:E8BF41FB-5C78-425B-8239-76C5741D7ACD[ at ]microsoft.com...
[Quoted Text]
> That helps. I want the input box to close when the cancel button is
> pressed,
> but to re-open if no Value is entered, but the OK button is pressed. Is
> there
> a method that I can differentiate between which oft the two buttons is
> pressed on the input box?
>
> "Douglas J. Steele" wrote:
>
>> It's the same check for both errors:
>>
>> Private Sub AddRemove_Click()
>> On Error GoTo Err_ADDRemove_Click
>>
>> Dim DocName As String
>> Dim StCriteria As String
>>
>> Dim stMsg As String
>> Dim stInput As String
>>
>> DocName = "WPAddRemove"
>>
>> stMsg = "Enter FCSI number"
>> 'Prompt for input
>> stInput = InputBox(stMsg)
>> If Len(stInput) = 0 Then
>> MsgBox "You must spupply an FCSI number."
>> Else
>> StCriteria = BuildCriteria("FCSI_ID", dbInteger, stInput)
>> StCriteria = StCriteria & "And " & "[Vessel_ID]=" & Me![Vessel_ID]
>> DoCmd.OpenForm DocName, , , StCriteria
>> Forms!WPAddRemove!WP_ID.DefaultValue = "" & Me![WP_Key] & ""
>> End If
>>
>> Exit_ADDRemove_Click:
>> Set rs = Nothing
>> Set qdf = Nothing
>> Set db = Nothing
>> Exit Sub
>>
>> Err_ADDRemove_Click:
>> MsgBox Err.Description
>> Resume Exit_ADDRemove_Click
>>
>> End Sub
>>
>>
>>
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "kharpe" <kharpe[ at ]discussions.microsoft.com> wrote in message
>> news:40189CC2-4875-4723-87D9-4CBFAD305CF0[ at ]microsoft.com...
>> >I have a form with a button used to open a second form. The SQL code
>> >behind
>> > the button opens an input box for user input of an "FCSI Number". When
>> > the
>> > user enters a valid FCSI number, the second form opens correctly.
>> > There
>> > are
>> > two instances during which I recieve an error. The first is if the user
>> > cancels the input box, and the second is if no value is entered for the
>> > "FCSI
>> > number"
>> >
>> > The above is the code for the sub. If anyone can help me with capturing
>> > the
>> > two errors it would be apreciated.
>> >
>>
>>
>>


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net