Solved

MSAccess Form Recordsource change

Posted on 2009-05-19
3
435 Views
Last Modified: 2013-11-28
Hello,

I am trying to change the recordsource of a form from another form. When the user clicks on the name of the client in the first form, second form should be displayed about the client which was chosen in the first form.
When I try to run this, it says 'it cannot find the frmclientssearchsub2 in the list of forms.
and highlights the
Me!frmClientsSearchSub2.Form.RecordSource = strsql
section.
I suspect the syntax should be different.
thanks,
Private Sub ClientName_DblClick(Cancel As Integer)
Dim strsql As String
 
 
Dim strwhere As String
strsql = "Select * From Assets"
strwhere = "1"
If Not IsNull(Me.Form.ClientName) Then
strwhere = strwhere & " AND LastName= '" & Me.Form.ClientName & "'"
End If
DoCmd.OpenForm ("searchform2")
 
Me!frmClientsSearchSub2.Form.RecordSource = strsql
 
 
 
End Sub

Open in new window

0
Comment
Question by:awesomejohn19
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:ctpmn1
ID: 24425800
Is the name of the form you are trying to pull frmClientsSearchSub2 ? If not then you should start there.
0
 

Author Comment

by:awesomejohn19
ID: 24426354
yes the name is frmClientsSearchSub2 and it is inside searchform2
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 24429015
awesomejohn19,

1. I cannot see were you are inserting the word "WHERE" in you SQL?

2. I can even see what Field you are trying to use the "1" for?

3. If all the values in the SQL string are hardcoded, then keep things "Simple" and put them all togeather in one string, so this is "easy" to troubleshoot.

4. You should be referring to the company ID, not the Name.

5. It looks like yor final SQL is Malformed.

6. It is not clear if the  1  is really a text datatype ("1"), or a numeric Datatype (1)

In any event, this works fine for me...

JeffCoachman


Access-EEQ24422068--ChangeFormRe.mdb
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question