5 Replies - 531 Views - Last Post: 28 November 2016 - 10:52 AM

#1 Bonekit  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 71
  • Joined: 09-May 16

Linking frmMain with sfrmIncome

Posted 27 November 2016 - 04:43 AM

Hello Folks,

I want to link frmMain and sfrmIncome. sfrmIncome is integrated over the Navigation Element as subform. But what should i enter to link the forms?

Regards,
Tobias
Is This A Good Question/Topic? 0
  • +

Replies To: Linking frmMain with sfrmIncome

#2 Bonekit  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 71
  • Joined: 09-May 16

Re: Linking frmMain with sfrmIncome

Posted 28 November 2016 - 02:42 AM

I hope this explains my situation better :)

I create a main form in access 2016.
Then i created a navigation element, with one button "navIncome". This navButton is loading my subform "sfrmIncome" as Datasheet without "Where = " entry.

But the subform shows my every record in sfrmIncome, i want that sfrmIncome show my only that records from the ID on frmMain.

ex: frmMain ID = 201611, now sfrmIncome should only show all Income from 201611.
How can i do that?

Sorry for my bad english

Regards
Tobias
Was This Post Helpful? 0
  • +
  • -

#3 Bonekit  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 71
  • Joined: 09-May 16

Re: Linking frmMain with sfrmIncome

Posted 28 November 2016 - 08:39 AM

Maybe there is a way to fix my problem:

I found a solution on youtube, but something i did wrong.

Private Sub txtIDRecord_AfterUpdate() 'Linking frmMain with sfrmEinkommen
'Declaration
    Dim strDateID As String
    
'Creating SQL-String to link frmMain with sfrmEinkommen
    strDateID = " SELECT * FROM tblEinkommen WHERE ([Datum_ID] = " & Me.txtIDRecord & ")"
    Me.navsub.Form.RecordSource = strDateID
    Me.navsub.Form.Requery
End Sub



This Code is not working, because "navsub" is the subform from frmMain. And sfrmIncome is the sub sub form from frmMain.
But Me.navsub!sfrmIncome.Form.RecordSource = strDateID is not working.

What can i do?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13566
  • View blog
  • Posts: 54,125
  • Joined: 12-June 08

Re: Linking frmMain with sfrmIncome

Posted 28 November 2016 - 10:17 AM

Copy/paste the error here.

Examine this as if the database would. How do you indicate, in a database, a string of characters? Typically tick marks around it. Are there tick marks in your string you are trying to build here?

6    strDateID = " SELECT * FROM tblEinkommen WHERE ([Datum_ID] = " & Me.txtIDRecord & ")"

Was This Post Helpful? 0
  • +
  • -

#5 Bonekit  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 71
  • Joined: 09-May 16

Re: Linking frmMain with sfrmIncome

Posted 28 November 2016 - 10:50 AM

There is no Error, only the problem that the subform shows all data and not only the data from the id.

Second: No, i guess im not sure i understand your question.
The ID in Me.txtIDRecord are only numbers.
Posted Image
Posted Image
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13566
  • View blog
  • Posts: 54,125
  • Joined: 12-June 08

Re: Linking frmMain with sfrmIncome

Posted 28 November 2016 - 10:52 AM

How would you normally write the query when directly querying SQL?

SELECT *
FROM <table name>
WHERE col1_name = '<some value>'

Tick marks indicate a varchar string. Your query doesn't have them so it treats the data you are appending like a column name.

If you can - use parameterized queries.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1