wee bit code...

lynsey2

Registered User.
Local time
Today, 04:33
Joined
Jun 18, 2002
Messages
439
cant seem to work out how to fix this code to work for me does anyone have a clue??

Private Sub SelectDrugs_Click()

Dim Ref As Integer
Dim MyRS As Recordset
Dim MySearch As String
Set MyRS = CurrentDb.OpenRecordset("his2", dbOpenDynaset)
Ref = Me.SelectDrugs.Column(0)
MySearch = "[Ref]=" & Ref
MyRS.Find MySearch
Forms!ARTScript!pickDrug1 = MyRS("Drug")
Forms!ARTScript!pickForm1 = MyRS("Form")
Forms!ARTScript!pickFreq1 = MyRS("Frequency")
Forms!ARTScript!pickStrength1 = MyRS("Strength")
Forms!ARTScript!txtIssued = MyRS("Date_Issued")
End Sub

i have a form with 2 list boxes on it, in the 2nd list box i have this code in the on_click event and i want the Drug, form, freq and strength from the 2nd list box to fill out text boxes in another form (ARTScript) i dont have a clue if im on the right lines so if anyone can help that would be great!
Thanks a million,
Lyns:p
 
Where does it fail?

PS MyRS.Close ought to be at the end!
 
Seems to be something wrong with

Set MyRS = CurrentDb.OpenRecordset("his2", dbOpenDynaset)

his2 being the table the 2nd box is based on!
 
Make sure:

1/ That you have Microsoft DAO 3.6 Object Library selected in references

2/ Declare MyRS as DAO.Recordset

HTH
 
so should the end bit work to fill out the text boxes on another form?????

i tried to do the DAO.Recordset but it didnt like that either ... invalid argument keeps coming up! :(
 
MyRS.Find MySearch

method or data member not found??????

got the DAO bit working i think i selected the wrong one in references.
 
TA!

getting there eh! thanks a million for helping. hopefuly i only have one problem left!

run time error 2450 cant find the form ARTScript in a macro expression or visual basic code.

i forgot how to fix this...my form is called ARTScript spelt the same too. :(

chances are this isnt going to work anyway! :rolleyes:
 
You need to open the form ARTScript before you can assign values to the controls. ie somewhere near the top of your code

DoCmd.OpenForm "ARTScript"
 
your a star*!

might have another wee question in a min if i cant work it out.

TA! thanks cheers for helping! :D

in the words of Arny ... i'll be back!!!

:rolleyes: :D
 

Users who are viewing this thread

Back
Top Bottom