Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4025072
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:48:03+00:00 2026-05-20T10:48:03+00:00

I hope someone here can help me! :) Actually I’ve run into a wall

  • 0

I hope someone here can help me! 🙂 Actually I’ve run into a wall with my VBA recently. I try to made a search form to find some specific field in the Access database. I successfully receive the information I need (Name, place, etc) from a SQL query but when I try to put all of this into a subform, I fail. I find the code below on internet and, execept the fact that the program don’t crash, it does absolutly nothing. My really problem (I think) is that I don’t know the right synthax to add value after the “addNewRecord”.

Set dbs = CurrentDb

WriteToATextFile (sqlquery)
Set rst = dbs.OpenRecordset(sqlquery)


rst.MoveFirst
Do While Not rst.EOF

   If Me!sfrm_recherche_cours.Form.Dirty Then
        Me!sfrm_recherche_cours.Form.Dirty = False
    End If

    Me!sfrm_recherche_cours.SetFocus
    MsgBox rst!titre_cours
    DoCmd.GoToRecord , , acNewRec
    txt_sigle_cours = rst!sigle_cours
    txt_titre_cours = rst!titre_cours
    txt_nrc_cours = rst!titre_cours
    txt_faculte_cours = rst!faculte_cours


   rst.MoveNext
Loop

I try to find something on this site that looks like my problem but I’ve got nothing…so, if you can put me on the right way, I will be very happy:)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:48:04+00:00Added an answer on May 20, 2026 at 10:48 am

    You appear to be running from the main form, but you are not adding a refernce to the subform to your controls, it should be:

    Set dbs = CurrentDb
    
    WriteToATextFile (sqlquery)
    Set rst = dbs.OpenRecordset(sqlquery)
    
    
    rst.MoveFirst
    Do While Not rst.EOF
    
       If Me!sfrm_recherche_cours.Form.Dirty Then
            Me!sfrm_recherche_cours.Form.Dirty = False
        End If
    
        Me!sfrm_recherche_cours.SetFocus
        MsgBox rst!titre_cours
        DoCmd.GoToRecord , , acNewRec
        Me!sfrm_recherche_cours.Form.txt_sigle_cours = rst!sigle_cours
        Me!sfrm_recherche_cours.Form.txt_titre_cours = rst!titre_cours
        Me!sfrm_recherche_cours.Form.txt_nrc_cours = rst!titre_cours
        Me!sfrm_recherche_cours.Form.txt_faculte_cours = rst!faculte_cours
    
    
       rst.MoveNext
    Loop
    

    However, it is often easier to simply run an append query and the requery the subform.

     sSQL="INSERT INTO MySubformTable " _
       & "(sigle_cours, titre_cours, nrc_cours, faculte_cours) " _
       & "SELECT sigle_cours, titre_cours, nrc_cours, faculte_cours " _
       & "FROM SomeOtherOrEvenTheSameTable " _
       & "WHERE SomeField=SomeNumber"
    
     dbs.Execute sSQL, dbFailOnError
     Me!sfrm_recherche_cours.Form.Requery
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope someone here can help me, i been trying to create an placeable
I hope someone here can help me. Im using selenium to test a page
I am pretty new to javascript so I hope someone here can help me
I hope someone in here can help me out because I am a bit
I hope someone can help... This issue has been discussed here and I have
thats my first question here and i hope someone can help me. I´m new
I hope someone can help me since I have no clue whats going on
I have a very strange issue, that I'm hoping someone here can help me
I hope someone can help me with this Javascript. I have an Object called
I hope someone can help as I'm at my wits end with this. What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.