Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / July 2007

Tip: Looking for answers? Try searching our database.

run-time error 3075

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rwilliams616 - 23 Jul 2007 19:08 GMT
Hi I have the following code:

Private Sub Form_BeforeInsert(Cancel As Integer)
Me.FileNo = Nz(DMax("[FileNo]", "tblFiles", "[LogNo] = " & Me.LogNo)) + 1
End Sub

I get the run-time error for the '[LogNo] = ' portion of the code.  LogNo is
a primary key in a table called tblFRACAS.  LogNo is also used in tblFiles.  
LogNo is linked in a one-to-many relationship between tblFRACAS and tblFiles.
It is an integer in each of the tables.

This code is being used in a subform called frmFiles.  The main form is
called frmFRACAS.

Can anyone offer any help?
Allen Browne - 24 Jul 2007 03:55 GMT
The code assumes that your form has controls named FileNo and LogNo. Do you
have both controls on your form?

Although VBA highlights the "[LogNo] = " part, the error could be anywhere
in the line.

I notice that you are running this code in Form_BeforeInsert. Will the LogNo
text box actually have a value at this stage? It might (if there's a default
value), but if not, the code will fail, and you may need to move it into the
AfterUpdate event procedure of the LogNo text box and test it for null:

   If Not IsNull(Me.LogNo) Then
       Me.FileNo = Nz(DMax("[FileNo]", "tblFiles", "[LogNo] = " &
Me.LogNo), 0) + 1
   End If

I've also suggested supplying the 2nd argument for Nz().

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Hi I have the following code:
>
[quoted text clipped - 14 lines]
>
> Can anyone offer any help?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.