« 6TH POPE Home | Email msg. | Reply to msg. | Post new | Board info. Previous | Home | Next

Re: Access Question for Zimbler - got it!

By: Decomposed in 6TH POPE | Recommend this post (0)
Mon, 23 May 22 4:19 AM | 34 view(s)
Boardmark this board | 6th Edition Pope Board
Msg. 32183 of 60008
(This msg. is a reply to 32182 by Zimbler0)

Jump:
Jump to board:
Jump to msg. #

I spent about 5 hours getting this small amount of code to work. But it finally does. Here's the syntax used in the form's Title field AfterUpdate event.:

Private Sub Title_AfterUpdate()
Dim x As Integer
  x = DupTitleCount()
  If x <> 0 Then MsgBox ("Prior copies in the database: " & x)
End Sub

Public Function DupTitleCount() As Integer
  DupTitleCount = DCount("[Title]", "tblMedia", "[tblMedia].[Title] = '" & Forms![frmMedia]![Title] & "'")
End Function

Thanks for the suggestions, Zim!




Avatar

Gold is $1,581/oz today. When it hits $2,000, it will be up 26.5%. Let's see how long that takes. - De 3/11/2013 - ANSWER: 7 Years, 5 Months


- - - - -
View Replies (1) »



» You can also:
- - - - -
The above is a reply to the following message:
Re: Access Question for Zimbler
By: Zimbler0
in 6TH POPE
Mon, 23 May 22 4:02 AM
Msg. 32182 of 60008

Decomposed > If I modify the prior procedure and function slightly to respond to the AfterUpdate event instead of the LostFocus event, I get a different error that suggests to me that Access can't see the Title of the form.


I have a feeling that what you need most, is to take the value out of the text box and then access it via VBA.

On the design view of the form, try right clicking on the 'Title' field. Click 'Properties'. You should get a Text Box with a title informing you it is for a 'Text Box:' and the name of that text box. The 'Other' tab should confirm the name.

In the database I'm looking at, I was calculating a tangent line. And I wanted to enter the x-coordinate of a point and a 'distance'. The x coordinate field was called 'xin'.

In the code module, I declared a variable named ex1 as a Double. To get my x-coordinate into VBA where I could do math on it, I used :

ex1 = xin.value

I would try getting the name off your form by pulling it out of the field on the form, then run your 'find duplicate' code.

Zim.


« 6TH POPE Home | Email msg. | Reply to msg. | Post new | Board info. Previous | Home | Next