Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 15th, 2004, 03:33 PM
SecuritasMatt SecuritasMatt is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 6 SecuritasMatt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool Populate Form on Opening

OK, I'm sure I'm being stupid here; hopefully someone can set me straight.
I want to open a new form, sorting by a field on the old form ("PassNumber"),
and if the sort turns up empty, input the value of "PassNo" on the new form
automatically, based on the value of "PassNumber" on the old form. Both
forms use separate tables.

I added a button control, used the wizard to do the basic sort code, and then
added in an if/then statement. Apparently I've got something wrong, because
I keep getting "Type Mismatch" error when this bit runs. Table column types
and form control types are identical in both tables and forms. Any ideas? Is
it something incredibly simple and idiotic?

Private Sub PPItemAdd_Click()
On Error GoTo Err_PPItemAdd_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim intPPRecord As Integer

intPPRecord = Me![PassNumber]
stDocName = "PropertyData"
stLinkCriteria = "[PassNo]=" & Me![PassNumber]

DoCmd.OpenForm stDocName, , , stLinkCriteria

If "[PassNo]= Null" Then
Value.[PropertyData].[PassNo] = intPPRecord
End If

Exit_PPItemAdd_Click:
Exit Sub

Err_PPItemAdd_Click:
MsgBox Err.Description
Resume Exit_PPItemAdd_Click

End Sub

Reply With Quote
  #2  
Old December 15th, 2004, 05:41 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
Hi SecuritasMatt

Change this part of your code

If "[PassNo]= Null" Then
Value.[PropertyData].[PassNo] = intPPRecord
End If

To This

If IsNull(Forms.PropertyData![PassNo]) Then
Forms.PropertyData![PassNo].Value = intPPRecord
End If

lwells

Reply With Quote
  #3  
Old December 17th, 2004, 11:35 AM
SecuritasMatt SecuritasMatt is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 6 SecuritasMatt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks again, you're a great help too all us noobs!
Can you tell it's been about 7 years since I've last played with VB??

Incidentally, if anyone else is doing something like this - since Access
"number" types default to "0", which is a valid number rather than a true null,
instead of:

IsNull(Forms.PropertyData![PassNo])

I had to make it:

(Forms.PropertyData![PassNo]) = 0

to make this work properly.

Quote:
Originally Posted by lwells

Change this part of your code

If "[PassNo]= Null" Then
Value.[PropertyData].[PassNo] = intPPRecord
End If

To This

If IsNull(Forms.PropertyData![PassNo]) Then
Forms.PropertyData![PassNo].Value = intPPRecord
End If

lwells

Reply With Quote
  #4  
Old December 17th, 2004, 04:41 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
Thanks,

Had forgotten about that. Although I am sure someone will remove the default value of zero and leave a true Null in the number field and really mess us both up...

Cheers
lwells

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Populate Form on Opening


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT