Using VB code in creating a dialog to be used with Access 2002

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

sUsing a dialog box to search for records, which I had used in Access 97,
using VB code, will not work in Access 2002. It is only 5 lines of code, but
it hangs up on "Compile Error Method or data member not found." If copy of
code is need to clearify please advise.
 
Does the code compile before you run it?

Also, by dialog, do you mean the msgbox command, inputbox command, or do you
mean an actual custom form that waits for input, and is a dialog form?


I mean, if it is only 4 or 5 lines of code..then it is just fine to post it
in your message. (where as posting 100 lines would not likely be read by
anyone!!).

I would try compiling the code first.....

The msgbox command did ever so slightly change from a97, to a2000 and beyond
(but, generally the code still works fine).
 
Thank you so much for repling. I'll try to be as short as possible - I
created a form by design which would pop-up and I would select a record to
view and when slected it would clone that record for viewing and editting.
(Code)
Private Sub ShowRecord_Click()
'Find the selected record, then close the dialog box.
 
Thank-you for replying, I'll try to keep this as short as possible. I created
a dialog for box by design. Which when I clicked on a command button Show
Record it would pop up and I could select a record from a scroll list and the
record would then show.
(Code)
Private Sub ShowRecord_Click()
'Find the selected record, then close the dialog box.
Dim rst As Recordset

'Store the recordset for the Subscribers form.
Set rst = Forms!Subscribers.RecordsetClone

'Locate the record for the selected subscriber.
rst.FindFirst "SubscriberID ="& SelectInfo

'Set the form's Bookmark property to move to the record.
Forms!Subscribers.Bookmark = rst.Bookmark

'Close the dialog box.
DoCmd.Close acForm, "GoToRecordDialog"

End Sub

When you run the code it hangs up on "SelectInfo" Compile Error Method or
data member not found.
 
'Locate the record for the selected subscriber.
rst.FindFirst "SubscriberID ="& SelectInfo

When you run the code it hangs up on "SelectInfo" Compile Error Method or
data member not found.

Yes, it appears from your code example that SelectInfo is not defined? Where
is SelectInfo comming from?
 
When I created the form I used the "List Box" draged it to the design pad and
saved and named it "SelectInfo"
 
F. L. Chidester Sr said:
When I created the form I used the "List Box" draged it to the design pad
and
saved and named it "SelectInfo"

Ok..that sounds good to me...

....and select info is in our form. Normally, you could go

And, perahps you can try

However, before we start changing the code...we now need to anser the other
question I asked..and that was does the code compile?
(while looking at code..go debug->compile...)
 
No when I compile it it stops at and highlights "SelectInfo" and the message
box appears with the info - Compile error - I also tried to add the
me.SelectInfo with the same result.
 
Ah..as you can see..we always want to "compile" our code before we try and
run it...

So, our code in running on a form, and in that form we have a listbox. Are
you sure of the name of the listbox?

Or is that listbox in the other form?

Remember, a text box control, or listbox does NOT need to be the same name
as the underlying field, or data set (and, in your case..it is not clear if
the listbox is un-bound).

Often, a lot of developers will ALWAYS use separate names from the field
names. So, you can place a text box on a screen called:

txtLastName

But, in fact, the above control is bound to a field called LastName. So,
control names, and what fields they are bound do not have to be the same
(but often are).

So, did you double check the name of the listbox you have on the
form...(while looking at the from, flip it into design mode..and click once
on the listbox.....is the name the same as what you have in code?

And, if that listbox is on another form then where the code is running, the
obviously, you have to qualify the forms name and tell he code what form you
are to find this info..

rst.FindFirst "SubscriberID ="& forms!YourFormNaameGoesHere!SelectInfo

As mentioned, you only need forms!YourFormNameGoesHere if the control you
are using in code is not on the same form as the code.

Also, if subscriberID is a text value, then you need to surround the
condition with quotes...(but lets get the code compiling first..BEFORE we
even try to run the code...). Once we get the code compiled..then we can
start the debugging process...
 
OK I have copied the information and will start from scratch to amke sure
every thing is the same as you have out lined. I thank you for thus far
taking some much time to work on this with me - it is 1:15 PM Edst here and
I'll be back around 6:00PM this evening. Thank You again.
 
Back
Top