PC Review


Reply
Thread Tools Rate Thread

Could some one please Help! Sorry no one answered my question.

 
 
Data
Guest
Posts: n/a
 
      20th Jul 2006
Hello Experts,

I need help.

First question: I have a main form (Clients) which allows user to
select from a list of client ID's. A number of textboxes or fields get
filled up. Now one of these textboxes is called Condition or the
condition field. I now press a command buttopn which opens the
orientation form.
In the orientation form, I want to display records based on the text
in the Condition field in the Clients form.

Here is copy of my code(I placed in form_load event of the
orientation form).
I don't know where to put it in the orientation_click event(command
button on clients form) or in the form_load event for the orientation
form.

---------------------------------------------------------------------------------------------------------------------------------
Private sub Form_Load
Dim StrSearch As String

If Forms!Clients.Condition = GPM Then

StrSearch = "SELECT [Orientation Table].[Orientation Session
Number], [Orientation
Table].Date,"
StrSearch = StrSearch + " [Orientation Table].[Attendance Code]"
StrSearch = StrSearch + " FROM [Orientation Table]"
StrSearch = StrSearch + " WHERE ((([Orientation Table].[Orientation
Session
Number])<=2))"

DoCmd.RunSQL StrSearch

End If

End Sub

Also gives me errors:
'Error: Can't find the form clients referred to in microsgoft visual
basic code.
'End if not structured properly

If can suggest some resources or list of books to look at, for
beginning access vba programmers that would be great.

Thanks in advance

 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      20th Jul 2006
Since you're checking for a string value, you need quotes around the value.
Since you're running the code in the module associated with the form, and
since the control is on that form, you can use Me! instead of Forms!Clients:

If Me!Condition = "GPM" Then

I think that should solve the error you're getting.

Jeff Conrad has a list of references pointing to references to books at
http://home.bendbroadband.com/conrad...ces.html#Books

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


"Data" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello Experts,
>
> I need help.
>
> First question: I have a main form (Clients) which allows user to
> select from a list of client ID's. A number of textboxes or fields get
> filled up. Now one of these textboxes is called Condition or the
> condition field. I now press a command buttopn which opens the
> orientation form.
> In the orientation form, I want to display records based on the text
> in the Condition field in the Clients form.
>
> Here is copy of my code(I placed in form_load event of the
> orientation form).
> I don't know where to put it in the orientation_click event(command
> button on clients form) or in the form_load event for the orientation
> form.
>
> ---------------------------------------------------------------------------------------------------------------------------------
> Private sub Form_Load
> Dim StrSearch As String
>
> If Forms!Clients.Condition = GPM Then
>
> StrSearch = "SELECT [Orientation Table].[Orientation Session
> Number], [Orientation
> Table].Date,"
> StrSearch = StrSearch + " [Orientation Table].[Attendance Code]"
> StrSearch = StrSearch + " FROM [Orientation Table]"
> StrSearch = StrSearch + " WHERE ((([Orientation Table].[Orientation
> Session
> Number])<=2))"
>
> DoCmd.RunSQL StrSearch
>
> End If
>
> End Sub
>
> Also gives me errors:
> 'Error: Can't find the form clients referred to in microsgoft visual
> basic code.
> 'End if not structured properly
>
> If can suggest some resources or list of books to look at, for
> beginning access vba programmers that would be great.
>
> Thanks in advance
>



 
Reply With Quote
 
 
 
 
Data
Guest
Posts: n/a
 
      20th Jul 2006

Douglas J. Steele wrote:
> Since you're checking for a string value, you need quotes around the value.
> Since you're running the code in the module associated with the form, and
> since the control is on that form, you can use Me! instead of Forms!Clients:
>
> If Me!Condition = "GPM" Then
>
> I think that should solve the error you're getting.
>
> Jeff Conrad has a list of references pointing to references to books at
> http://home.bendbroadband.com/conrad...ces.html#Books
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Data" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello Experts,
> >
> > I need help.
> >
> > First question: I have a main form (Clients) which allows user to
> > select from a list of client ID's. A number of textboxes or fields get
> > filled up. Now one of these textboxes is called Condition or the
> > condition field. I now press a command buttopn which opens the
> > orientation form.
> > In the orientation form, I want to display records based on the text
> > in the Condition field in the Clients form.
> >
> > Here is copy of my code(I placed in form_load event of the
> > orientation form).
> > I don't know where to put it in the orientation_click event(command
> > button on clients form) or in the form_load event for the orientation
> > form.
> >
> >


Hello David,

Thanks

But someone suggested another way, I don't know where to put the code
though.


tina wrote:
> well, i probably wouldn't filter (restrict) the records in the 2nd form's
> Load event. since you're filtering based on data entered in a control in the
> 1st form, it's easier to refer to that control from within that form; i'd
> use the WHERE argument of the DoCmd.OpenForm action, in the Click event
> procedure of the command button in the 1st form, as


> If Me!Condition = "GPM" Then
> DoCmd.OpenForm "OrientationFormName", , , _
> "[Orientation Session Number]<=2"
> Else
> DoCmd.OpenForm "OrientationFormName"
> End If


> substitute the correct form name, of course. note that the above places
> quotes around "GPM" on the assumption that it is a text value in the 1st
> form's control.


> hth


Thanks Tina.

Altough I am not sure why the code's not working. I placed it in the
right location?

Private Sub cmdOrientation_Click()

If Me!Condition = "GPM" Then
DoCmd.OpenForm "Orientation", , , _
"[Orientation Session number]<=2"
Else
DoCmd.OpenForm "Orientation"
End If

'On Error GoTo Err_cmdOrientation_Click

' Dim stDocName As String
' Dim stLinkCriteria As String

' stDocName = "Orientation"
' DoCmd.OpenForm stDocName, , , stLinkCriteria

'Exit_cmdOrientation_Click:
' Exit Sub

'Err_cmdOrientation_Click:
' MsgBox Err.Description
' Resume Exit_cmdOrientation_Click

End Sub

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      20th Jul 2006
Heck, I was so busy noticing the lack of quotes that I completely missed the
fact that you're trying to use RunSQL with a SELECT query. You can't. RunSQL
is only for Action queries (INSERT INTO, UPDATE, DELETE)

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


"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:(E-Mail Removed)...
> Since you're checking for a string value, you need quotes around the

value.
> Since you're running the code in the module associated with the form, and
> since the control is on that form, you can use Me! instead of

Forms!Clients:
>
> If Me!Condition = "GPM" Then
>
> I think that should solve the error you're getting.
>
> Jeff Conrad has a list of references pointing to references to books at
>

http://home.bendbroadband.com/conrad...ces.html#Books
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Data" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello Experts,
> >
> > I need help.
> >
> > First question: I have a main form (Clients) which allows user to
> > select from a list of client ID's. A number of textboxes or fields get
> > filled up. Now one of these textboxes is called Condition or the
> > condition field. I now press a command buttopn which opens the
> > orientation form.
> > In the orientation form, I want to display records based on the text
> > in the Condition field in the Clients form.
> >
> > Here is copy of my code(I placed in form_load event of the
> > orientation form).
> > I don't know where to put it in the orientation_click event(command
> > button on clients form) or in the form_load event for the orientation
> > form.
> >

>
> --------------------------------------------------------------------------

-------------------------------------------------------
> > Private sub Form_Load
> > Dim StrSearch As String
> >
> > If Forms!Clients.Condition = GPM Then
> >
> > StrSearch = "SELECT [Orientation Table].[Orientation Session
> > Number], [Orientation
> > Table].Date,"
> > StrSearch = StrSearch + " [Orientation Table].[Attendance Code]"
> > StrSearch = StrSearch + " FROM [Orientation Table]"
> > StrSearch = StrSearch + " WHERE ((([Orientation Table].[Orientation
> > Session
> > Number])<=2))"
> >
> > DoCmd.RunSQL StrSearch
> >
> > End If
> >
> > End Sub
> >
> > Also gives me errors:
> > 'Error: Can't find the form clients referred to in microsgoft visual
> > basic code.
> > 'End if not structured properly
> >
> > If can suggest some resources or list of books to look at, for
> > beginning access vba programmers that would be great.
> >
> > Thanks in advance
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where to from here if no-one answered a question? Please help! =?Utf-8?B?a25lZWRlZXA=?= Microsoft Access 4 26th Jul 2005 05:29 PM
sorry TEST sorry THE GRYLION Asus Motherboards 2 29th Mar 2005 09:29 AM
Re: sorry still cant seem to write formulas in a word chart can some one please help JulieD Microsoft Word New Users 3 23rd Sep 2004 06:52 PM
sorry about the earlier post this is the real one sorry neo Windows XP Performance 1 26th Aug 2004 02:19 PM
Sorry, sorry, sorry... db199 Windows XP Security 0 21st Sep 2003 01:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:15 PM.