|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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:
|
|
#4
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Populate Form on Opening |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|