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:)
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:
However, it is often easier to simply run an append query and the requery the subform.